Alarm Manager Basics: Setting Up a Simple Alarm
We will start the chapter with setting an alarm at a particular time and having it call a broadcast receiver. Once the broadcast receiver is invoked, we can use the information from Chapter 19 to perform both simple and long-running operations in that broadcast receiver.
The steps are as follows:
- Get access to the alarm manager.
- Come up with a time to set the alarm.
- Create a receiver to be invoked.
- Create a pending intent that can be passed to the alarm manager to invoke the receiver at the appointed time.
- Use the time instance from step 2 and the pending intent from step 4 to set the alarm.
- See the receiver from step 3 invoked.
Getting Access to the Alarm Manager
Getting access to the alarm manager ...
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.