Native Android Broadcast Actions

Android broadcasts Intents for many of the system Services. You can use these messages to add functionality to your own projects based on system events such as time-zone changes, data-connection status, incoming SMS messages, or phone calls.

The following list introduces some of the native actions exposed as constants in the Intent class; these actions are used primarily to track device status changes.

> action_boot_completed Fired once when the device has completed its startup sequence. An application requires the receive_boot_completed permission to receive this broadcast.

> action_camera_button Fired when the camera button is clicked.

> action_date_changed and action_time_changed These actions are broadcast if the date or time on the device is manually changed (as opposed to changing through the inexorable progression of time).

> action_media_button Fired when the media button is clicked.

> action_media_eject If the user chooses to eject the external storage media, this event is fired first. If your application is reading or writing to the external media storage you should listen for this event in order to save and close any open file handles.

> action_media_mounted and action_media_unmounted These two events are broadcast whenever new external storage media are successfully added to or removed from the device.

> action_new_outgoing_call Broadcast when a new outgoing call is about to be placed. Listen for this broadcast to intercept outgoing calls. The number being dialed is stored in the extra_phone_number extra, while the resultData in the returned Intent will be the number actually dialed. To register a Broadcast Receiver for this action your application must declare the process_outgoing_calls uses-permission.

> action_screen_off and action_screen_on Broadcast when the screen turns off or on respectively.

> action_timezone_changed This action is broadcast whenever the phone's current time zone changes. The Intent includes a time-zone extra that returns the ID of the new java.util.TimeZone.

A comprehensive list of the broadcast actions used and transmitted natively by Android to notify applications of system state changes is available at content/Intent.html

Android also uses broadcast Intents to announce application-specific events like incoming SMS messages. The actions and Intents associated with these events will be discussed in more detail in later chapters when you learn more about the associated Services.

Was this article helpful?

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