Intentservice And Alarmmanager Communication
Should alarm manager send PendingIntent to IntentService or is it better to send it to a broadcast receiver which then issues startService() targeting the pending intent?
Solution 1:
That depends a bit on whether this is a _WAKEUP
alarm or not.
If not, feel free to use a getService()
PendingIntent
.
If, however, it is a _WAKEUP
alarm, not only do you need to use a BroadcastReceiver
intermediary, but that BroadcastReceiver
must also acquire a WakeLock
which the IntentService
later releases. The BroadcastReceiver
requirement is due to the way AlarmManager
handles its own WakeLock
. I have wrapped all of this up as a WakefulIntentService
to simplify the implementation.
Post a Comment for "Intentservice And Alarmmanager Communication"