When the user takes an action on some data, such as touching a mailto:[email protected] link, they are actually initiating an Intent object, or just an intent, which then gets resolved to a particular component (we consider only activity components here). So, the result of a user touching a mailto: link is an Intent object that the system tries to match to an activity. If that Intent object was written explicitly naming an activity (an explicit intent), then the system immediately launches that activity in response to the user action. However, if that Intent object was written without naming an activity (an implicit intent), the system compares the Intent object to the intent filters of available activities. If more than one activity can handle the action and data, the system displays an activity chooser for the user to choose from.
This example of touching the mailto: link is shown in the following figure. If the device has two email applications set up, when a user touches a mailto: email address on a web page, the result is an Intent object which displays a dialog box with a choice between the two activities to compose an email (Gmail and Email).
Here are some examples of Intent objects and the activities they resolve to:
• View the list of contacts - resolves to a contact list viewer activity
• View a particular contact - resolves to a contact viewer activity
• Edit a particular contact - resolves to a contact editor activity
• Send to a particular email - resolves to an email activity
• Dial a phone number - resolves to a phone dialer activity
• View the list of images - resolves to an image list viewer activity
• View a particular image - resolves to an image viewer activity
• Crop a particular image - resolves to an image cropper activity Notice that an Intent object specifies two things, an action and data:
• A generic action to be performed. In these examples: view, edit, dial or crop
• The specific data to be acted on. In these examples: the list of contacts, a particular contact, a phone number, the list of images, or a particular image
Note that any user action to start an activity from the application launcher at Home is an explicit intent to a specific activity. Likewise, some activities launch private activities within their application as explicit intents so no other activity can access them.
For more on intents, see Intent class and intent filters
Was this article helpful?