Handling alarms
So far we have learned how to schedule exact and inexact alarms over the AlarmManager Service
singleton, so at this point we are ready to take a look at how to handle the alarm in any Android application component.
Essentially, we can schedule anything that can be started with a PendingIntent
, which means we can use alarms to start Activities, Services, and BroadcastReceivers
. To specify the target of our alarm, we need to use the static factory methods of PendingIntent
:
PendingIntent.getActivities(Context, int,Intent[],int) PendingIntent.getActivity(Context,int, Intent, int) PendingIntent.getService(Context,int, Intent, int) PendingIntent.getBroadcast(Context,int, Intent, int)
All static methods offered to create a pending intent, receiving as arguments a Context object, an integer request code to identify the pending intent, an Intent or an array of Intents that will be delivered to the component, and finally an integer to specify the PendingIntent
flags.
The PendingIntent
...