

To get around this, however, a flag can be added to the intent before it is sent to indicate that the intent is to be allowed to start a component of a stopped application. An application is considered to be in a stopped state if the application has either just been installed and not previously launched, or been manually stopped by the user using the application manager on the device. This is because Android 3.0 introduced a launch control security measure that prevents components of stopped applications from being launched via an intent. On more recent versions of Android, however, the intent would not be received by the broadcast receiver. The above code would successfully launch the corresponding broadcast receiver on a device running an Android version earlier than 3.0. For example, the following code fragment creates and sends a broadcast intent including a unique action string and data: Intent intent = new Intent() The action string, which identifies the broadcast event, must be unique and typically uses the application’s Java package name syntax. The optional category string may be assigned to a broadcast intent via a call to the addCategory() method. As with standard intents, data is added to a broadcast intent using key-value pairs in conjunction with the putExtra() method of the intent object. When a broadcast intent is created, it must include an action string in addition to optional data and a category string. In addition to providing a messaging and event system between application components, broadcast intents are also used by the Android system to notify interested applications about key system events (such as the external power supply or headphones being connected or disconnected).

Broadcast intents are Intent objects that are broadcast via a call to the sendBroadcast(), sendStickyBroadcast() or sendOrderedBroadcast() methods of the Activity class (the latter being used when results are required from the broadcast).
