Exploring Alarm Manager Alternate Scenarios
Now that we have explained the basics of setting an alarm, we will cover a few additional scenarios, such as setting off an alarm repeatedly and cancelling alarms. We will also show you exception conditions that you may run into while using the alarm manager.
Setting Off an Alarm Repeatedly
We have already covered how to set a simple one-time alarm, so let’s now consider how we can set an alarm that goes of repeatedly; see Listing 20–9.
public void sendRepeatingAlarm()
{
Calendar cal = Utils.getTimeAfterInSecs(30);
String s = Utils.getDateTimeString(cal);
//Get an intent to invoke the receiver
Intent intent = new Intent(this.mContext, ...
Get Pro Android 4 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.