Login     Sign Up
Tugadar (@admin)
21 days ago
20 Views

Native Android applications also use Intents to launch Activities and sub-Activities.

The following noncomprehensive list shows some of the native actions available as static string con-stants in the Intent class. You can use these actions when creating implicit Intents to start Activities and sub-Activities within your own applications.

In the next section you will be introduced to Intent Filters, and you’ll learn how to register your own Activities as handlers for these actions.

❑ACTION_ANSWER Opens an Activity that handles incoming calls. Currently this is handled by the native phone dialer.

❑ACTION_CALL Brings up a phone dialer and immediately initiates a call using the number sup-plied in the data URI. Generally, it’s considered better form to use the Dial_Action if possible.

❑ACTION_DELETE Starts an Activity that lets you delete the entry currently stored at the data URI location.

❑ACTION_DIAL Brings up a dialer application with the number to dial prepopulated from the data URI. By default, this is handled by the native Android phone dialer. The dialer can normal-ize most number schemas; for example, tel:555-1234 and tel:(212) 555 1212 are both valid numbers.

❑ACTION_EDIT Requests an Activity that can edit the data at the URI.

❑ACTION_SEND Launches an Activity that sends the specified data (the recipient needs to be selected by the resolved Activity). Use setType to set the Intent’s type as the transmitted data’s mime type.

The data itself should be stored as an extra using the key EXTRA_TEXT or EXTRA_STREAM depending on the type. In the case of e-mail, the native Android applications will also accept extras using the EXTRA_EMAIL, EXTRA_CC, EXTRA_BCC, and EXTRA_SUBJECT keys.

❑ACTION_VIEW The most common generic action. View asks that the data supplied in the Intent’s URI be viewed in the most reasonable manner. Different applications will handle view requests depending on the URI schema of the data supplied. Natively, http: addresses will open in the browser, tel: addresses will open the dialer to call the number, geo: addresses are displayed in the Google Maps application, and contact content will be displayed in the Contact Manager.

❑ACTION_WEB_SEARCH Opens an activity that performs a Web search based on the text sup-plied in the data URI.

As well as these Activity actions, Android includes a large number of Broadcast actions that are used to create Intents that the system broadcasts to notify applications of events. These Broadcast actions are described later in this chapter.