Note

For the applications in this chapter, you will use two of the Intents listed in Table 7-1: CALL_ACTION and DIAL_ACTION. These Intents give you access to the phone's dialing and calling capabilities.

Table 7-2 lists and describes the current Broadcast Intents that are available. Refer to this list when you need to establish a receiver for a specific Intent.

Broadcast Intent

Message

CALL_FORWARDING_STATE_CHANGED_ACTION

The phone's call forwarding state has changed

CAMERA_BUTTON_ACTION

The camera button has been pressed

CONFGURATION_CHANGED_ACTION

The device's configuration has changed

data_activity_state_changed_action

The device's data activity state has changed

DATA_CONNECTION_STATE_CHANGED_ACTION

There has been a change in the data connection state

DATE_CHANGED_ACTION

The phone's system date has changed

FOTA_CANCEL_ACTION

Cancel pending system update downloads

FOTA_INSTALL_ACTION

An update has been downloaded and must be installed immediately (sent by the system)

FOTA_READY_ACTION

An update has been downloaded and can be installed—but does not need to be installed immediately (sent by the system)

FOTA_RESTART_ACTION

Restart a system update download

FOTA_UPDATE_ACTION

Begin the download of a system update

GTALK_SERVICES_CONNECTED_ACTION

Sent when a GTALK session has been successfully established

GTALK_SERVICES_DISCONNECTED_ACTION

Sent when a GTALK session has been disconnected

MEDIA_BAD_REMOVAL_ACTION

Sent when an SD Memory Card was removed but unsuccessfully unmounted from the system

MEDIA_BUTTON_ACTION

Sent when the media button has been pressed

Table 7-2 Broadcast Intents

Broadcast Intent

Message

MEDIA_EJECT_ACTION

Sent when the eject action has been initiated on an SD Memory Card

MEDIA_MOUNTED_ACTION

Sent when an SD Memory Card was successfully mounted to the system

MEDIA_REMOVED_ACTION

Sent when an SD memory card was detected as having been removed

MEDIA_SCANNER_FINISHED_ACTION

Sent when the scanner has finished

MEDIA_SHARED_STARTED_ACTION

Sent when the scanner has begun

MEDIA_UNMOUNTED_ACTION

Sent when an SD memory card has been detected but has not been mounted

MESSAGE_WAITING_STATE_CHANGED

The "message waiting" state on the phone has changed

NETWORK_TICKLE_RECEIVED_ACTION

A new device network notification has been received

PACKAGE_ADDED_ACTION

Sent when a new package has been installed on the device

PACKAGE_CHANGE_ACTION

Sent when an existing package has been modified

PACKAGE_INSTALL_ACTION

A package can be downloaded and installed

PACKAGE_REMOVED_ACTION

A package has been removed

PHONE_INTERFACE_ADDED_ACTION

The device's phone interface has been created

PHONE_STATE_CHANGED_ACTION

The device's phone state has changed

PROVIDER_CHANGED_ACTION

The device has received a notification from a provider

PROVISIONING_CHECK_ACTION

Check for the latest settings from the provisioning service

SCREEN_OFF_ACTION

The screen has been shut off (sent by the device)

SCREEN_ON_ACTION

The screen has been turned on (sent by the device)

SERVICE_STATE_CHANGED_ACTION

The service state has changed

SIGNAL_STRENGTH_CHANGED_ACTION

The signal strength has changed

Table 7-2 Broadcast Intents (continued)

Broadcast Intent

Message

SIM_STATE_CHANGED_ACTION

The state of the SIM card has changed

TIME_CHANGED_ACTION

The device's time was set

TIME_TICK_ACTION

The current time has changed

TIMEZONE_CHANGED_ACTION

The device's timezone has changed

UMS_CONNECTED_ACTION

The device has connected via USB

UMS_DISCONNECTED_ACTION

The device has been disconnected from its USB host

WALLPAPER_CHANGED_ACTION

The device's wallpaper has been changed

Table 7-2 Broadcast Intents (continued)

NOTE

Some of these Broadcast Intents are sent out quite often, such as TIME_TICK_ACTION and SIGNAL_STRENGTH_CHANGED_ACTION. Be careful how you use them. You should try not to receive such broadcasts if at all possible.

Some of these Broadcast Intents are sent out quite often, such as TIME_TICK_ACTION and SIGNAL_STRENGTH_CHANGED_ACTION. Be careful how you use them. You should try not to receive such broadcasts if at all possible.

The Intent is only one-third of the picture. An Intent is really just that, an intent to do something; an Intent cannot actually do anything by itself. You need Intent Filters and Intent Receivers to listen for, and interpret, the Intents.

An Intent Receiver is like the mailbox of an Activity. The Intent Receiver is used to allow an Activity to receive the specified Intent. Using the previous web browser example, the Web Browser Activity is set up to receive web browser Intents. A system like this allows unrelated Activities to ignore Intents that they would not be able to process. It also allows Activities that need the assistance of another Activity to utilize that Activity without needing to know how to call it.

With Intents and Intent Receivers, one Activity can send out an Intent and another can receive it. However, there needs to be something that governs the type of information that can be sent between the two Activities. This is where Intent Filters come in.

Intent Filters are used by Activities to describe the types of Intents they want to receive. More importantly, they outline the type of data that should be passed with the Intent. Therefore, in our example scenario, we want the web browser to open a web page. The Intent Filter would state that the data passed with the WEB_SEARCH_ACTION Intent should be in the form of a URL.

In the next section, you will begin to use Intents to open and utilize the phone's dialer.

0 0

Post a comment