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.

Listing 20–9. Setting a Repeating Alarm

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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.