To use Retrofit, you will need to begin by creating an interface definition for the REST API you want to target. Retrofit will then create an implementation of that interface that can be used to make synchronous or asynchronous HTTP web requests.
- [Narrator] The Retrofit package…will create an implementation of an interface…that you can use to communicate with a REST API.…Github in this case.…Lets go ahead and define this interface.…In the project outline on the left,…right-click the data package in Model,…and create a new Java class.…Select Interface from the Kind field drop down,…and call it IGitHubService,…click OK to create it.…
We will define all of our API methods in this interface.…But, before we write any of them,…let's take a look at the main viewModel class,…in the viewModel package on the left.…This class handles mostly all the logic for the application.…And, is where we will use Retrofit…to create an implementation…of the interface we just defined.…First, we should add a property to this class.…Below the isLoggedInProperty,…add a new private,…IGitHubService…called mGitHubService.…
Scroll down a little bit more…and in the initAnonService method,…we need to create a new Retrofit instance,…called Retrofit,…and using the Retrofit builder sequence,…by creating a new Retrofit.Builder…
- 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.