Service is a base class of service implementation. Service runs on the application’s main thread which may reduce the application performance. Thus, IntentService, which is a direct subclass of Service is available to make things easier.
The IntentService is used to perform a certain task in the background. Once done, the instance of IntentService terminates itself automatically. Examples for its usage would be to download a certain resource from the Internet.
Differences
Serviceclass uses the application’s main thread, whileIntentServicecreates a worker thread and uses that thread to run the service.IntentServicecreates a queue that passes one intent at a time toonHandleIntent(). Thus, implementing a multi-thread should be made by extendingServiceclass directly.
Serviceclass needs a manual stop usingstopSelf(). Meanwhile,IntentServiceautomatically stops itself when it finishes execution.IntentServiceimplementsonBind()that returnsnull. This means that theIntentServicecan not be bound by default.IntentServiceimplementsonStartCommand()that sends Intent to queue and toonHandleIntent().
In brief, there are only two things to do to use IntentService. Firstly, to implement the constructor. And secondly, to implement onHandleIntent(). For other callback methods, the super is needed to be called so that it can be tracked properly.