Semester : SEMESTER 6
Subject : Object Oriented Programming
Year : 2018
Term : MARCH
Scheme : 2015 Full Time
Course Code : EC 312
Page:22
A broadcast is a message that any app can receive. The system delivers various broadcasts for system
events, such as when the system boots up or the device starts charging. You can deliver a broadcast to
other apps by passing an Intent to sendBroadcast() or sendOrderedBroadcast().
Intent types
There are two types of intents: Explicit intents specify which application will satisfy the intent, by
supplying either the target app's package name or a fully-qualified component class name. You'll
typically use an explicit intent to start a component in your own app, because you know the class
name of the activity or service you want to start. For example, you might start a new activity within
your app in response to a user action, or start a service to download a file in the background.
Implicit intents do not name a specific component, but instead declare a general action to perform,
which allows a component from another app to handle it. For example, if you want to show the user a
location on a map, you can use an implicit intent to request that another capable app show a specified
location on a map.
An intent filter is an expression in an app's manifest file that specifies the type of intents that the
component would like to receive. For instance, by declaring an intent filter for an activity, you make it
possible for other apps to directly start your activity with a certain kind of intent. Likewise, if you do
not declare any intent filters for an activity, then it can be started only with an explicit intent.
Building an intent
An Intent object carries information that the Android system uses to determine which component to
start (such as the exact component name or component category that should receive the intent), plus
information that the recipient component uses in order to properly perform the action (such as the
action to take and the data to act upon).
The primary information contained in an Intent is the following:
Component name
The name of the component to start.
This is optional, but it's the critical piece of information that makes an intent explicit, meaning that the
intent should be delivered only to the app component defined by the component name. Without a
component name, the intent is implicit and the system decides which component should receive the
intent based on the other intent information (such as the action, data, and category—described below).
If you need to start a specific component in your app, you should specify the component name.
Note: When starting a Service, always specify the component name. Otherwise, you cannot be certain
what service will respond to the intent, and the user cannot see which service starts.