Receiving a System Broadcast: Waking Up on Boot

PhotoGallery’s background alarm works, but it is not perfect. If the user reboots the device, the alarm will be forgotten.

Apps that perform an ongoing process for the user generally need to wake themselves up after the device is booted. You can detect when boot is completed by listening for a broadcast intent with the BOOT_COMPLETED action. The system sends out a BOOT_COMPLETED broadcast intent whenever the device is turned on. You can listen for it by creating and registering a standalone broadcast receiver that filters for the appropriate action.

Creating and registering a standalone receiver

A standalone receiver is a broadcast receiver that is declared in the manifest. Such ...

Get Android Programming: The Big Nerd Ranch Guide, Third Edition now with O’Reilly online learning.

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