Activating ComponentsThree of the four component types—activities, services, and broadcast receivers—are activated by an asynchronous message called an intent. Intents bind individual components to each other at runtime (you can think of them as the messengers that request an action from other components), whether the component belongs to your application or another. An intent is created with an For activities and services, an intent defines the action to perform (for example, to "view" or
"send" something) and may specify the URI of the data to act on (among other things that the
component being started might need to know). For example, an intent might convey a request for an
activity to show an image or to open a web page. In some cases, you can start an
activity to receive a result, in which case, the activity also returns
the result in an For broadcast receivers, the intent simply defines the announcement being broadcast (for example, a broadcast to indicate the device battery is low includes only a known action string that indicates "battery is low"). The other component type, content provider, is not activated by intents. Rather, it is
activated when targeted by a request from a There are separate methods for activating each type of component:
For more information about using intents, see the Intents and
Intent Filters document. More information about activating specific components is also provided
in the following documents: Activities, Services, |
|
来自: android之情殇 > 《android》