Making web service calls to RESTful web services can take quite a bit of code, but there are some great tools available that can make it a lot easier. One of these is an open-source library named Retrofit, created by the folks at Square. Retrofit lets you define web service locations and syntax in simple Java interfaces, and then handle web requests asynchronously without having to create your own threads or AsyncTask objects.
- [Narrator] Making web service calls to Restful web…services can take quite a bit of code.…But there's some great tools available…that can make it a lot easier.…One of these is an open source library named Retrofit,…created by the folks at Square.…Retrofit lets you define web service locations and syntax…in simple Java interfaces.…And then you can handle web service requests asynchronously,…without having to create your own threads…or async task objects.…Ill be working with this JSON formatted feed…that delivers a set of data objects.…
Each data object has properties called item name,…category, description and so on,…but I'm more going to concern myself…with two of those values,…the item name and the price.…In my starting application for this demonstration,…I've created a Java class named data item,…that has those two values declared as private fields…with public setters and getters.…The class also has an override of the two string method,…that delivers the data in an easy to read format.…
Now to work with Retrofit, the first thing I did…
First, discover how to create and start simple background threads, and how to use handlers to manage a thread's message queue. Then, learn various methods for optimizing the scheduling and performance of background tasks in Android with AsyncTask, intent services, and the JobScheduler API. Plus, explore tools that help you implement multithreading for different tasks in Android: Loader, for asynchronous data loading, and the open-source API Retrofit, for making HTTP requests.
Note: To get the most out of this course, you should be comfortable programming with Java, and should understand the most basic skills that are needed to build Android apps with the Android SDK and Android Studio.
- Creating and running a background thread
- Sending messages to the UI from threads
- Managing multiple background threads
- Managing threads with AsyncTask
- Managing long-running tasks with services
- Scheduling background tasks with JobScheduler
- Using other APIs for concurrent programming