RESTlient Using Service- An Android Mobile Reads

In this blog I will show you how to call REST API through a service. First question come to your mind that Why Service one use AsyncTask to call REST. Well, you can do that if you want to frustrate your user by calling same request again and again.

Basically the role of service is to continuously run in background without worrying about application process, or user interaction with application.

RESTService is made to implement as a subclass of services, while the services are meant to encapsulate longer running operations in an android app, they are not inherently threaded. This is something that often confuses new android developers. So we will create a new thread whenever new API request is fired. Here is the details of the code snippet

Continue reading

Advertisements