Instead of writing out each parameter or header on a one-to-one basis with the method definition, Retrofit supports the use of a key-value map to condense them into a single parameter passed to the method. You can use a single map annotated with the @QueryMap tag for query parameters or for headers with the @HeaderMap tag.
- [Instructor] Throughout this course, the methods…that we have defined for the sample application…have used only one query parameter.…There are many cases in which we may want to use more…than one query parameter though.…One such situation in the sample app,…is if we want to change the number of records loaded…whenever we get the list of gists or comments…from the GitHub API.…Let's take a look at the getPublicGists method…in the GitHub service interface.…By default the GitHub API returns 30 records per page…and we are using the page parameter to specify…which group of 30 records we would like to get.…
If we want to load more or less than 30 records at a time,…we can set the per_page query parameter…in the request to the number of records…we want to see per page,…like 10 or 15.…The simplest approach in this situation…is to add another parameter to the method definition.…Like an int called PerPage…with the appropriate query annotation,…Per_page, but what if you needed to add a third…or fourth or maybe fifth parameter?…
- REST API basics
- Methods for reading and writing data
- Defining data models with Retrofit
- Implementing an API interface
- Getting data with a Retrofit call
- Authorizing requests
- Putting, deleting, and posting data
- Customizing the data converter
- Working with the request and response headers
Skill Level Intermediate
Android App Development: Enterprise Integrationwith Jon-Luke West47m 51s Intermediate
Android App Development: Data Persistence Librarieswith Annyce Davis4h 52m Intermediate
1. HTTP APIs
2. Get Started with Retrofit
3. Finish the Sample App
4. More Configuration Options
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.