O'Reilly logo

Pro Android 4 by Satya Komatineni, Dave MacLean

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required