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