What Are Intents

Before you can begin to interact with the phone dialer, you need to understand the type of code that you will use to do the job. Android uses Intents to do specific jobs within applications. Once you master the use of Intents, a whole new world of application development will be open to you. This section defines what an Intent is and how it is used.

An Intent is Android's method for relaying certain information from one Activity to another. An Intent, in simpler terms, expresses to Android your intent to do something. You can think of an Intent as a message passed between Activities. For example, assume that you have an Activity that needs to open a web browser and display a page on your Android device. Your Activity would send an "intent to open x page in the web browser," known as a WEB_SEARCH_ACTION Intent, to the Android Intent Resolver. The Intent Resolver parses through a list of Activities and chooses the one that would best match your Intent; in this case, the Web Browser Activity. The Intent Resolver then passes your page to the web browser and starts the Web Browser Activity. Intents are broken up into two main categories:

• Activity Action Intents Intents used to call Activities outside of your application. Only one Activity can handle the Intent. For example, for a web browser, you need to open the Web Browser Activity to display a page.

• Broadcast Intents Intents that are sent out for multiple Activities to handle. An example of a Broadcast Intent would be a message sent out by Android about the current battery level. Any Activity can process this Intent and react accordingly—for example, cancel an Activity if the battery level is below a certain point.

Table 7-1 lists and describes the current Activity Action Intents that are available to you. As you'll notice, in most cases, the name of the Intent does a good job of describing what that Intent does.

Activity Action Intent



Add a function shortcut to the Android Home Screen


List all the applications available on the device


Answer an incoming call


Open the Bug Reporting Activity


Place a call to supplied location


Delete the specified data


Open the Dial Activity and dial the specified number


Provide editable access to the supplied data


Dial an emergency number


Retrieve factory test settings


Select and return specified data


Insert an empty item


Establish the Activity start point


Pick an item and return the selection


Pick a given Activity (returns a class)


Execute the given data


Launch a search on the system


Send data without specifying the recipient


Send data to the recipient specified


Launch System Settings


Sync phone data with external source


Open a View


Show settings for modifying the Android Wallpaper


Open Google Search, or another web page if specified

Table 7-1 Activity Action Intents

Table 7-1 Activity Action Intents

0 0

Post a comment