tags:

views:

622

answers:

1

Hi all,

I was trying to get the purpose of the IntentService, and when should I use it?

I tried to understand from the API, but not enough details on that one.

Is there any analogy between this and running long-task on a working thread?

Any further explanation and samples on why I would use IntentService would be very welcome.

Thanks,

ray.

+3  A: 

Is there any analogy between this and running long-task on a working thread?

IntentService handles the thread for you.

when should I use it?

Some use cases:

  • For handling alarms triggered by AlarmManager
  • For handling other events caught by a manifest-registered BroadcastReceiver
  • For handling events triggered by an app widget (time-based updates, button clicks, etc.)
CommonsWare
Why i better use IntentService for "handling alarms triggered by AlarmManager/manifest-registered BroadcastReceiver", what it can do that regular Service wont be able to?
rayman
@rayman: it handles the background thread and work queue for you.
CommonsWare
I think i got it, but mybe you know some example i could check, so i can see the slight diffrence between using it or not?thanks.
rayman
@rayman: http://github.com/commonsguy/cw-andtutorials/tree/master/36-AdvAppWidget/ http://github.com/commonsguy/cwac-wakeful
CommonsWare