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

Message

ADD_SHORTCUT_ACTION

Add a function shortcut to the Android Home Screen

ALL_APPS_ACTION

List all the applications available on the device

ANSWER_ACTION

Answer an incoming call

BUG_REPORT_ACTION

Open the Bug Reporting Activity

CALL_ACTION

Place a call to supplied location

DELETE_ACTION

Delete the specified data

DIAL_ACTION

Open the Dial Activity and dial the specified number

EDIT_ACTION

Provide editable access to the supplied data

EMERGENCY_DIAL_ACTION

Dial an emergency number

FACTORY_TEST_ACTION

Retrieve factory test settings

GET_CONTENT_ACTION

Select and return specified data

INSERT_ACTION

Insert an empty item

MAIN_ACTION

Establish the Activity start point

PICK_ACTION

Pick an item and return the selection

PICK_ACTIVITY_ACTION

Pick a given Activity (returns a class)

RUN_ACTION

Execute the given data

SEARCH_ACTION

Launch a search on the system

SEND_ACTION

Send data without specifying the recipient

SENDTO_ACTION

Send data to the recipient specified

SETTINGS_ACTION

Launch System Settings

SYNC_ACTION

Sync phone data with external source

VIEW_ACTION (DEFAULT_ACTION)

Open a View

WALLPAPER_SETTINGS_ACTION

Show settings for modifying the Android Wallpaper

WEB_SEARCH_ACTION

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