RSS

Service vs Intent service

26 May

Service

  1. Task with no UI,but should not use for long Task. Use Thread within service for long Task
  2. invoke by onStartService()
  3. Triggered from any Thread
  4. Runs On Main Thread
  5. May block main(UI) thread

IntentService

  1. Long task usually no communication with main thread if communication is needed then it is done by Handler or broadcast
  2. invoke via Intent
  3. triggered from Main Thread (Intent is received on main Thread and worker thread is spawed)
  4. runs on separate thread
  5. can’t run task in parallel and multiple intents are Queued on the same worker thread.
Advertisements
 
Leave a comment

Posted by on May 26, 2014 in Android Tips & Tricks

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: