Thursday, February 14, 2013

The Differences between Service and IntentService in Android


Differences

  • Service class uses the application's main thread, while IntentService creates a worker thread and uses that thread to run the service.
  • IntentService creates a queue that passes one intent at a time to onHandleIntent(). Thus, implementing a multi-thread should be made by extending Service class directly.
  • Service class needs a manual stop using stopSelf(). Meanwhile, IntentService automatically stops itself when there is no intent in queue. 
  • IntentService implements onBind() that returns null. This means that the IntentService can not be bound by default.
  • IntentService implements onStartCommand() that sends Intent to queue and to onHandleIntent().

No comments:

Post a Comment