Available for download on

Wrox.com (AlarmManager)getSystemService(Context.ALARM_SERVICE);

String MY_RTC_ALARM = "MY_RTC_ALARM"; String ALARM_ACTION = "MY_ELAPSED_ALARM";

Pendinglntent rtcIntent =

PendingIntent.getBroadcast(this, 0, new Intent(MY_RTC_ALARM), 1);

continues

LISTING 9-26 (continued)

Pendinglntent elapsedlntent =

PendingIntent.getBroadcast(this, 0, new Intent(ALARM_ACTION), 1);

// Wakeup and fire intent in 5 hours. Date t = new Date();

t.setTime(java.lang.System.currentTimeMillis() + 60*1000*5); alarms.set(AlarmManager.RTC_WAKEUP, t.getTime(), rtclntent);

// Fire intent in 3 0 mins if already awake.

alarms.set(AlarmManager.ELAPSED_REALTIME, 30*60*1000, elapsedlntent);

// Cancel the first alarm. alarms.cancel(rtclntent);

Mobile Apps Made Easy

Mobile Apps Made Easy

Quick start guide to skyrocket your offline and online business success with mobile apps. If you know anything about mobile devices, you’ve probably heard that famous phrase coined by one of the mobile device’s most prolific creators proclaiming that there’s an app for pretty much everything.

Get My Free Training Guide


Post a comment