Friday, February 3, 2017

Service vs Intent service - Android

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.

No comments :

Post a Comment