Handling alarms with BroadcastReceiver
We met BroadcastReceiver
already in Chapter 5, Interacting with Services, where we used it in an Activity
to receive broadcasts from a Service
. In this section, we'll use BroadcastReceiver
to handle alarms set on the AlarmManager
.
BroadcastReceivers
can be registered and unregistered dynamically at runtime like we did in Chapter 5, Interacting with Services, with Service
, or statically in the Android manifest file with a <receiver>
element, and can receive alarms regardless of how they are registered.
It is more common to use a statically registered receiver for alarms, because these are known to the system and can be invoked by alarms to start an application if it is not currently running.
Let's implement ...
Get Asynchronous Android Programming - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.