Communication IntentService and AlarmManager

Should the alarm manager send a PendingIntent to an IntentService, or is it better to send it to the broadcast receiver, which then issues startService () based on the pending intent?

+3
source share
1 answer

It depends a little on whether it is a signal _WAKEUPor not.

If not, feel free to use getService() PendingIntent.

If, however, it is an alarm _WAKEUP, you need to not only use the intermediary BroadcastReceiver, but you BroadcastReceivermust also get WakeLockone that will be released later IntentService. The requirement BroadcastReceiveris related to how it AlarmManagerprocesses its own WakeLock. I have simplified the implementation of this process as WakefulIntentService.

+10
source

Source: https://habr.com/ru/post/1791793/


All Articles