Reference:Android.content.Intent
From Triled Wiki
android.content
public class android.content.Intent
| java.lang.Object | ||
| android.content.Intent | Parcelable | |
An intent is an abstract description of an operation to be performed. It can be used with startActivity to launch an Activity, broadcastIntent to send it to any interested IntentReceiver components, and startService(Intent, Bundle) or bindService(Intent, ServiceConnection, int) to communicate with a background Service.
An Intent provides a facility for performing late runtime binding between the code in different applications. Its most significant use is in the launching of activities, where it can be thought of as the glue between activities. It is basically a passive data structure holding an abstract description of an action to be performed. The primary pieces of information in an intent are:
- action - The general action to be performed, such as VIEW_ACTION, EDIT_ACTION, MAIN_ACTION, etc.
- data - The data to operate on, such as a person record in the contacts database, expressed as a Uri.
Some examples of action/data pairs are:
- VIEW_ACTION content://contacts/1 - Display information about the person whose identifier is "1".
- EDIT_ACTION content://contacts/1 - Edit information about the person whose identifier is "1".
- VIEW_ACTION content://contacts/ - Display a list of people, which the user can browse through. This example is a typical top-level entry into the Contacts application, showing you the list of people. Selecting a particular person to view would result in a new intent { VIEW_ACTION content://contacts/N } being used to start an activity to display that person.
- PICK_ACTION content://contacts/ - Display the list of people, allowing the user to browse through them and pick one and return it to the parent activity. This could be used, for example, if an e-mail application wanted to allow the user to pick a person.
In addition to these primary attributes, there are a number of secondary attributes that you can also include with an intent:
- category - Gives additional information about the action to execute. For example, LAUNCHER_CATEGORY means it should appear in the Launcher as a top-level application, while ALTERNATIVE_CATEGORY means it should be included in a list of alternative actions the user can perform on a piece of data.
- type - Specifies an explicit type (a MIME type) of the intent data. Normally the type is inferred from the data itself. By setting this attribute, you disable that evaluation and force an explicit type.
- component - Specifies an explicit name of a component class to use for the intent. Normally this is determined by looking at the other information in the intent (the action, data/type, and categories) and matching that with a component that can handle it. If this attribute is set then none of the evaluation is performed, and this component is used exactly as is. By specifying this attribute, all of the other Intent attributes become optional.
- extras - This is a Bundle of any additional information. This can be used to provide extended information to the component. For example, if we have a action to send an e-mail message, we could also include extra pieces of data here to supply a subject, body, etc.
There are a variety of standard Intent action and category constants defined in the Intent class, but applications can also define their own. These strings use Java style scoping, to ensure they are unique - for example, the standard VIEW_ACTION is called "android.app.action.VIEW".
Put together, the set of actions, data types, categories, and extra data defines a language for the system allowing for the expression of phrases such as "call john smith's cell". As applications are added to the system, they can extend this language by adding new actions, types, and categories, or they can modify the behavior of existing phrases by supplying their own activities that handle them.
[edit] Intent Resolution
There are two primary forms of intents you will use.
- Explicit Intents have specified a component (via setComponent(ComponentName) or )">setClass(Context, Class) ), which provides the exact class to be run. Often these will not include any other information, simply being a way for an application to launch various internal activities it has as the user interacts with the application.
- Implicit Intents have not specified a component; instead, they must include enough information for the system to determine which of the available components is best to run for that intent.
When using implicit intents, given such an arbitrary intent we need to know what to do with it. This is handled by the process of Intent resolution, which maps an Intent to an Activity, IntentReceiver, or Service (or sometimes two or more activities/receivers) that can handle it.
The intent resolution mechanism basically revolves around matching an Intent against all of the <intent-filter> descriptions in the installed application packages. (Plus, in the case of broadcasts, any IntentReceiver objects explicitly registered with registerReceiver(IntentReceiver, IntentFilter).) More details on this can be found in the documentation on the IntentFilter class.
There are three pieces of information in the Intent that are used for resolution: the action, type, and category. Using this information, a query is done on the PackageManager for a component that can handle the intent. The appropriate component is determined based on the intent information supplied in the AndroidManifest.xml file as follows:
- The action, if given, must be listed by the component as one it handles.
- The type is retrieved from the Intent's data, if not already supplied in the Intent. Like the action, if a type is included in the intent (either explicitly or implicitly in its data), then this must be listed by the component as one it handles.
- For data that is not a content: URI and where no explicit type is included in the Intent, instead the scheme of the intent data (such as http: or mailto:) is considered. Again like the action, if we are matching a scheme it must be listed by the component as one it can handle.
- The categories, if supplied, must all be listed by the activity as categories it handles. That is, if you include the categories LAUNCHER_CATEGORY and ALTERNATIVE_CATEGORY, then you will only resolve to components with an intent that lists both of those categories. Activities will very often need to support the DEFAULT_CATEGORY so that they can be found by Context.startActivity().
For example, consider the Note Pad sample application that allows user to browse through a list of notes data and view details about individual items. Text in italics indicate places were you would replace a name with one specific to your own package.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="''com.google.android.notepad''">
<application android:icon="@drawable/app_notes"
android:label="@string/app_name">
<provider class=".NotePadProvider"
android:authorities="''com.google.provider.NotePad''" />
<activity class=".NotesList" android:label="@string/title_notes_list">
<intent-filter>
<action android:value="android.intent.action.MAIN" />
<category android:value="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:value="android.intent.action.VIEW" />
<action android:value="android.intent.action.EDIT" />
<action android:value="android.intent.action.PICK" />
<category android:value="android.intent.category.DEFAULT" />
<type android:value="vnd.android.cursor.dir/''vnd.google.note''" />
</intent-filter>
<intent-filter>
<action android:value="android.intent.action.GET_CONTENT" />
<category android:value="android.intent.category.DEFAULT" />
<type android:value="vnd.android.cursor.item/''vnd.google.note''" />
</intent-filter>
</activity>
<activity class=".NoteEditor" android:label="@string/title_note">
<intent-filter android:label="@string/resolve_edit">
<action android:value="android.intent.action.VIEW" />
<action android:value="android.intent.action.EDIT" />
<category android:value="android.intent.category.DEFAULT" />
<type android:value="vnd.android.cursor.item/''vnd.google.note''" />
</intent-filter>
<intent-filter>
<action android:value="android.intent.action.INSERT" />
<category android:value="android.intent.category.DEFAULT" />
<type android:value="vnd.android.cursor.dir/''vnd.google.note''" />
</intent-filter>
</activity>
<activity class=".TitleEditor" android:label="@string/title_edit_title"
android:theme="@android:style/Theme.Dialog">
<intent-filter android:label="@string/resolve_title">
<action android:value="''com.google.android.notepad.action.EDIT_TITLE''" />
<category android:value="android.intent.category.DEFAULT" />
<category android:value="android.intent.category.ALTERNATIVE" />
<category android:value="android.intent.category.SELECTED_ALTERNATIVE" />
<type android:value="vnd.android.cursor.item/''vnd.google.note''" />
</intent-filter>
</activity>
</application>
</manifest>
The first activity, com.google.android.notepad.NotesList, serves as our main entry into the app. It can do three things as described by its three intent templates:
<intent-filter> <action android:value="[[#MAIN_ACTION|android.intent.action.MAIN]] " /> <category android:value="[[#LAUNCHER_CATEGORY|android.intent.category.LAUNCHER]] " /> </intent-filter>This provides a top-level entry into the NotePad application: the standard MAIN action is a main entry point (not requiring any other information in the Intent), and the LAUNCHER category says that this entry point should be listed in the application launcher.
<intent-filter> <action android:value="[[#VIEW_ACTION|android.intent.action.VIEW]] " /> <action android:value="[[#EDIT_ACTION|android.intent.action.EDIT]] " /> <action android:value="[[#PICK_ACTION|android.intent.action.PICK]] " /> <category android:value="[[#DEFAULT_CATEGORY|android.intent.category.DEFAULT]] " /> <type android:value="vnd.android.cursor.dir/''vnd.google.note''" /> </intent-filter>This declares the things that the activity can do on a directory of notes. The type being supported is given with the <type> tag, where vnd.android.cursor.dir/vnd.google.note is a URI from which a Cursor of zero or more items (vnd.android.cursor.dir) can be retrieved which holds our note pad data (vnd.google.note). The activity allows the user to view or edit the directory of data (via the VIEW and EDIT actions), or to pick a particular note and return it to the caller (via the PICK action). Note also the DEFAULT category supplied here: this is required for the Context.startActivity method to resolve your activity when its component name is not explicitly specified.
<intent-filter> <action android:value="[[#GET_CONTENT_ACTION|android.intent.action.GET_CONTENT]] " /> <category android:value="[[#DEFAULT_CATEGORY|android.intent.category.DEFAULT]] " /> <type android:value="vnd.android.cursor.item/''vnd.google.note''" /> </intent-filter>This filter describes the ability return to the caller a note selected by the user without needing to know where it came from. The data type vnd.android.cursor.item/vnd.google.note is a URI from which a Cursor of exactly one (vnd.android.cursor.item) item can be retrieved which contains our note pad data (vnd.google.note). The GET_CONTENT action is similar to the PICK action, where the activity will return to its caller a piece of data selected by the user. Here, however, the caller specifies the type of data they desire instead of the type of data the user will be picking from.
Given these capabilities, the following intents will resolve to the NotesList activity:
- { action=android.app.action.MAIN } matches all of the activities that can be used as top-level entry points into an application.
- { action=android.app.action.MAIN, category=android.app.category.LAUNCHER } is the actual intent used by the Launcher to populate its top-level list.
- { action=android.app.action.VIEW data=content://com.google.provider.NotePad/notes }displays a list of all the notes under "content://com.google.provider.NotePad/notes", which the user can browse through and see the details on.
- { action=android.app.action.PICK data=content://com.google.provider.NotePad/notes }provides a list of the notes under "content://com.google.provider.NotePad/notes", from which the user can pick a note whose data URL is returned back to the caller.
- { action=android.app.action.GET_CONTENT type=vnd.android.cursor.item/vnd.google.note }is similar to the pick action, but allows the caller to specify the kind of data they want back so that the system can find the appropriate activity to pick something of that data type.
The second activity, com.google.android.notepad.NoteEditor, shows the user a single note entry and allows them to edit it. It can do two things as described by its two intent templates:
<intent-filter android:label="@string/resolve_edit"> <action android:value="[[#VIEW_ACTION|android.intent.action.VIEW]] " /> <action android:value="[[#EDIT_ACTION|android.intent.action.EDIT]] " /> <category android:value="[[#DEFAULT_CATEGORY|android.intent.category.DEFAULT]] " /> <type android:value="vnd.android.cursor.item/''vnd.google.note''" /> </intent-filter>The first, primary, purpose of this activity is to let the user interact with a single note, as decribed by the MIME type vnd.android.cursor.item/vnd.google.note. The activity can either VIEW a note or allow the user to EDIT it. Again we support the DEFAULT category to allow the activity to be launched without explicitly specifying its component.
<intent-filter> <action android:value="[[#INSERT_ACTION|android.intent.action.INSERT]] " /> <category android:value="[[#DEFAULT_CATEGORY|android.intent.category.DEFAULT]] " /> <type android:value="vnd.android.cursor.dir/''vnd.google.note''" /> </intent-filter>The secondary use of this activity is to insert a new note entry into an existing directory of notes. This is used when the user creates a new note: the INSERT action is executed on the directory of notes, causing this activity to run and have the user create the new note data which it then adds to the content provider.
Given these capabilities, the following intents will resolve to the NoteEditor activity:
- { action=android.app.action.VIEW data=content://com.google.provider.NotePad/notes/{ID} }shows the user the content of note {ID}.
- { action=android.app.action.EDIT data=content://com.google.provider.NotePad/notes/{ID} }allows the user to edit the content of note {ID}.
- { action=android.app.action.INSERT data=content://com.google.provider.NotePad/notes }creates a new, empty note in the notes list at "content://com.google.provider.NotePad/notes" and allows the user to edit it. If they keep their changes, the URI of the newly created note is returned to the caller.
The last activity, com.google.android.notepad.TitleEditor, allows the user to edit the title of a note. This could be implemented as a class that the application directly invokes (by explicitly setting its component in the Intent), but here we show a way you can publish alternative operations on existing data:
<intent-filter android:label="@string/resolve_title"> <action android:value="''com.google.android.notepad.action.EDIT_TITLE''" /> <category android:value="[[#DEFAULT_CATEGORY|android.intent.category.DEFAULT]] " /> <category android:value="[[#ALTERNATIVE_CATEGORY|android.intent.category.ALTERNATIVE]] " /> <category android:value="[[#SELECTED_ALTERNATIVE_CATEGORY|android.intent.category.SELECTED_ALTERNATIVE]] " /> <type android:value="vnd.android.cursor.item/''vnd.google.note''" /> </intent-filter>
In the single intent template here, we have created our own private action called com.google.android.notepad.action.EDIT_TITLE which means to edit the title of a note. It must be invoked on a specific note (data type vnd.android.cursor.item/vnd.google.note) like the previous view and edit actions, but here displays and edits the title contained in the note data.
In addition to supporting the default category as usual, our title editor also supports two other standard categories: ALTERNATIVE and SELECTED_ALTERNATIVE. Implementing these categories allows others to find the special action it provides without directly knowing about it, through the queryIntentActivityOptions(ComponentName, Intent[], Intent, int) method, or more often to build dynamic menu items with addIntentOptions(int, int, ComponentName, Intent[], Intent, int, Menu.Item[]). Note that in the intent template here was also supply an explicit name for the template (via android:label="@string/resolve_title") to better control what the user sees when presented with this activity as an alternative action to the data they are viewing.
Given these capabilities, the following intent will resolve to the TitleEditor activity:
- { action=com.google.android.notepad.action.EDIT_TITLE data=content://com.google.provider.NotePad/notes/{ID} }displays and allows the user to edit the title associated with note {ID}.
[edit] Standard Activity Actions
These are the current standard actions that Intent defines for launching activities (usually through startActivity(Intent). The most important, and by far most frequently used, are MAIN_ACTION and EDIT_ACTION.
- MAIN_ACTION
- VIEW_ACTION
- EDIT_ACTION
- PICK_ACTION
- GET_CONTENT_ACTION
- DIAL_ACTION
- CALL_ACTION
- SEND_ACTION
- SENDTO_ACTION
- ANSWER_ACTION
- INSERT_ACTION
- DELETE_ACTION
- RUN_ACTION
- SYNC_ACTION
- PICK_ACTIVITY_ACTION
- SEARCH_ACTION
- WEB_SEARCH_ACTION
- FACTORY_TEST_ACTION
[edit] Standard Broadcast Actions
These are the current standard actions that Intent defines for receiving broadcasts (usually through registerReceiver(IntentReceiver, IntentFilter) or a <receiver> tag in a manifest).
- TIME_TICK_ACTION
- TIME_CHANGED_ACTION
- TIMEZONE_CHANGED_ACTION
- BOOT_COMPLETED_ACTION
- PACKAGE_ADDED_ACTION
- PACKAGE_REMOVED_ACTION
- BATTERY_CHANGED_ACTION
[edit] Standard Categories
These are the current standard categories that can be used to further clarify an Intent via addCategory(String).
- DEFAULT_CATEGORY
- BROWSABLE_CATEGORY
- TAB_CATEGORY
- ALTERNATIVE_CATEGORY
- SELECTED_ALTERNATIVE_CATEGORY
- LAUNCHER_CATEGORY
- HOME_CATEGORY
- PREFERENCE_CATEGORY
- GADGET_CATEGORY
- TEST_CATEGORY
[edit] Standard Extra Data
These are the current standard fields that can be used as extra data via putExtra(String, Bundle).
[edit] Launch Flags
These are the possible launch flags that can be used in the Intent via setLaunchFlags(int) and addLaunchFlags(int).
- NO_HISTORY_LAUNCH
- SINGLE_TOP_LAUNCH
- NEW_TASK_LAUNCH
- MULTIPLE_TASK_LAUNCH
- FORWARD_RESULT_LAUNCH
[edit] Nested Classes
| Intent.FilterComparison | Wrapper class holding an Intent and implementing comparisons on it for the purpose of filtering. |
[edit] Summary
[edit] Constants
| Value | ||||
|---|---|---|---|---|
| String | ADD_SHORTCUT_ACTION | Activity Action: Add a new shortcut to the system. | "android.intent.action.ADD_SHORTCUT" | |
| String | ALL_APPS_ACTION | Activity Action: List all available applications
Input: Nothing. | "android.intent.action.ALL_APPS" | |
| String | ALTERNATIVE_CATEGORY | Set if the activity should be considered as an alternative action to the data the user is currently viewing. | "android.intent.category.ALTERNATIVE" | |
| String | ANSWER_ACTION | Activity Action: Handle an incoming phone call. | "android.intent.action.ANSWER" | |
| String | BATTERY_CHANGED_ACTION | Broadcast Action: The charging state, or charge level of the battery has changed. | "android.intent.action.BATTERY_CHANGED" | |
| String | BOOT_COMPLETED_ACTION | Broadcast Action: This is broadcast once, after the system has finished booting. | "android.intent.action.BOOT_COMPLETED" | |
| String | BROWSABLE_CATEGORY | Activities that can be safely invoked from a browser must support this category. | "android.intent.category.BROWSABLE" | |
| String | BUG_REPORT_ACTION | Activity Action: Show activity for reporting a bug. | "android.intent.action.BUG_REPORT" | |
| String | CALL_ACTION | Activity Action: Perform a call to someone specified by the data. | "android.intent.action.CALL" | |
| String | CALL_FORWARDING_STATE_CHANGED_ACTION | Broadcast Action: The phone's voice call forwarding (unconditional) state has changed. | "android.intent.action.CFF" | |
| String | CAMERA_BUTTON_ACTION | Broadcast Action: The "Camera Button" was pressed. | "android.intent.action.CAMERA_BUTTON" | |
| String | CONFIGURATION_CHANGED_ACTION | Broadcast Action: The current device Resources.Configuration (orientation, locale, etc) has changed. | "android.intent.action.CONFIGURATION_CHANGED" | |
| Creator | CREATOR | |||
| String | DATA_ACTIVITY_STATE_CHANGED_ACTION | Broadcast Action: The phone's data activity state has changed. | "android.intent.action.DATA_ACTIVITY" | |
| String | DATA_CONNECTION_STATE_CHANGED_ACTION | Broadcast Action: The phone's data connection state has changed. | "android.intent.action.DATA_STATE" | |
| String | DATE_CHANGED_ACTION | Broadcast Action: The date has changed. | "android.intent.action.DATE_CHANGED" | |
| String | DEFAULT_ACTION | A synonym for VIEW_ACTION, the "standard" action that is performed on a piece of data. | "android.intent.action.VIEW" | |
| String | DEFAULT_CATEGORY | Set if the activity should be an option for the default action (center press) to perform on a piece of data. | "android.intent.category.DEFAULT" | |
| String | DELETE_ACTION | Activity Action: Delete the given data from its container. | "android.intent.action.DELETE" | |
| String | DEVELOPMENT_PREFERENCE_CATEGORY | This activity is a development preference panel. | "android.intent.category.DEVELOPMENT_PREFERENCE" | |
| String | DIAL_ACTION | Activity Action: Dial a number as specified by the data. | "android.intent.action.DIAL" | |
| String | EDIT_ACTION | Activity Action: Provide explicit editable access to the given data. | "android.intent.action.EDIT" | |
| String | EMBED_CATEGORY | Capable of running inside a parent activity container. | "android.intent.category.EMBED" | |
| String | EMERGENCY_DIAL_ACTION | Activity Action: Dial an emergency number. | "android.intent.action.EMERGENCY_DIAL" | |
| int | EXCLUDE_FROM_RECENTS_LAUNCH | If set, the new activity is not kept in the list of recently launched activities. | 32 | 0x00000020 |
| String | FACTORY_TEST_ACTION | Activity Action: Main entry point for factory tests. | "android.intent.action.FACTORY_TEST" | |
| int | FORWARD_RESULT_LAUNCH | If set and this intent is being used to launch a new activity from an existing one, then the reply target of the existing activity will be transfered to the new activity. | 16 | 0x00000010 |
| String | FOTA_CANCEL_ACTION | Broadcast Action: Sent to cancel any pending update downloads. | "android.server.checkin.FOTA_CANCEL" | |
| String | FOTA_INSTALL_ACTION | Broadcast Action: Sent when an update is confirmed and should be installed immediately. | "android.server.checkin.FOTA_INSTALL" | |
| String | FOTA_READY_ACTION | Broadcast Action: Sent when an update is downloaded and ready for install. | "android.server.checkin.FOTA_READY" | |
| String | FOTA_RESTART_ACTION | Broadcast Action: Trigger the resumption of a stalled update download. | "android.server.checkin.FOTA_RESTART" | |
| String | FOTA_UPDATE_ACTION | Broadcast Action: Trigger the download and eventual installation of an over-the-air (OTA) operating system update. | "android.server.checkin.FOTA_UPDATE" | |
| String | FRAMEWORK_INSTRUMENTATION_TEST_CATEGORY | To be used as code under test for framework instrumentation tests. | "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST" | |
| String | GADGET_CATEGORY | This activity can be embedded inside of another activity that is hosting gadgets. | "android.intent.category.GADGET" | |
| String | GET_CONTENT_ACTION | Activity Action: Allow the user to select a particular kind of data and return it. | "android.intent.action.GET_CONTENT" | |
| String | GTALK_SERVICE_CONNECTED_ACTION | Broadcast Action: An GTalk connection has been established. | "android.intent.action.GTALK_CONNECTED" | |
| String | GTALK_SERVICE_DISCONNECTED_ACTION | Broadcast Action: An GTalk connection has been disconnected. | "android.intent.action.GTALK_DISCONNECTED" | |
| String | HOME_CATEGORY | This is the home activity, that is the first activity that is displayed when the device boots. | "android.intent.category.HOME" | |
| String | INSERT_ACTION | Activity Action: Insert an empty item into the given container. | "android.intent.action.INSERT" | |
| String | INTENT_EXTRA | An Intent describing the choices you would like shown with PICK_ACTIVITY_ACTION, or the shortcut to add with ADD_SHORTCUT_ACTION. | "android.intent.extra.INTENT" | |
| String | KEY_EVENT_EXTRA | A KeyEvent object containing the event that triggered the creation of the Intent it is in. | "android.intent.extra.KEY_EVENT" | |
| String | LABEL_EXTRA | A CharSequence initial label to provide for the user when used with a ADD_SHORTCUT_ACTION. | "android.intent.extra.LABEL" | |
| String | LAUNCHER_CATEGORY | Should be displayed in the top-level launcher. | "android.intent.category.LAUNCHER" | |
| String | MAIN_ACTION | Activity Action: Start as a main entry point, does not expect to receive data. | "android.intent.action.MAIN" | |
| String | MEDIA_BAD_REMOVAL_ACTION | Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted. | "android.intent.action.MEDIA_BAD_REMOVAL" | |
| String | MEDIA_BUTTON_ACTION | Broadcast Action: The "Media Button" was pressed. | "android.intent.action.MEDIA_BUTTON" | |
| String | MEDIA_EJECT_ACTION | Broadcast Action: User has expressed the desire to remove the external storage media. | "android.intent.action.MEDIA_EJECT" | |
| String | MEDIA_MOUNTED_ACTION | Broadcast Action: External media is present and mounted at its mount point. | "android.intent.action.MEDIA_MOUNTED" | |
| String | MEDIA_REMOVED_ACTION | Broadcast Action: External media has been removed. | "android.intent.action.MEDIA_REMOVED" | |
| String | MEDIA_SCANNER_FINISHED_ACTION | Broadcast Action: The media scanner has finished scanning a directory. | "android.intent.action.MEDIA_SCANNER_FINISHED" | |
| String | MEDIA_SCANNER_STARTED_ACTION | Broadcast Action: The media scanner has started scanning a directory. | "android.intent.action.MEDIA_SCANNER_STARTED" | |
| String | MEDIA_SHARED_ACTION | Broadcast Action: External media is unmounted because it is being shared via USB mass storage. | "android.intent.action.MEDIA_SHARED" | |
| String | MEDIA_UNMOUNTED_ACTION | Broadcast Action: External media is present, but not mounted at its mount point. | "android.intent.action.MEDIA_UNMOUNTED" | |
| String | MESSAGE_WAITING_STATE_CHANGED_ACTION | Broadcast Action: The phone's message waiting (voicemail) state has changed. | "android.intent.action.MWI" | |
| int | MULTIPLE_TASK_LAUNCH | Used in conjunction with NEW_TASK_LAUNCH to disable the behavior of bringing an existing task to the foreground. | 8 | 0x00000008 |
| String | NETWORK_TICKLE_RECEIVED_ACTION | Broadcast Action: A new network "tickle" notification has been received by the device. | "android.intent.action.NETWORK_TICKLE_RECEIVED" | |
| int | NEW_TASK_LAUNCH | If set, this activity will become the start of a new task on this history stack. | 4 | 0x00000004 |
| int | NO_HISTORY_LAUNCH | If set, the new activity is not kept in the history stack. | 1 | 0x00000001 |
| String | OPENABLE_CATEGORY | Used to indicate that a GET_CONTENT intent only wants URIs that can be opened with ContentResolver.openInputStream. | "android.intent.category.OPENABLE" | |
| String | PACKAGE_ADDED_ACTION | Broadcast Action: A new application package has been installed on the device. | "android.intent.action.PACKAGE_ADDED" | |
| String | PACKAGE_CHANGED_ACTION | Broadcast Action: An existing application package has been changed (e.g. | "android.intent.action.PACKAGE_CHANGED" | |
| String | PACKAGE_INSTALL_ACTION | Broadcast Action: Trigger the download and eventual installation of a package. | "android.intent.action.PACKAGE_INSTALL" | |
| String | PACKAGE_REMOVED_ACTION | Broadcast Action: An existing application package has been removed from the device. | "android.intent.action.PACKAGE_REMOVED" | |
| String | PHONE_INTERFACE_ADDED_ACTION | Broadcast Action: The Phone interface is created. | "android.intent.action.PHONE_INTERFACE_ADDED" | |
| String | PHONE_STATE_CHANGED_ACTION |
Broadcast Action: The phone state has changed. | "android.intent.action.PHONE_STATE" | |
| String | PICK_ACTION | Activity Action: Pick an item from the data, returning what was selected. | "android.intent.action.PICK" | |
| String | PICK_ACTIVITY_ACTION | Activity Action: Pick an activity given an intent, returning the class selected. | "android.intent.action.PICK_ACTIVITY" | |
| String | PREFERENCE_CATEGORY | This activity is a preference panel. | "android.intent.category.PREFERENCE" | |
| String | PROVIDER_CHANGED_ACTION | Broadcast Action: Some content providers have parts of their namespace where they publish new events or items that the user may be especially interested in. | "android.intent.action.PROVIDER_CHANGED" | |
| String | PROVISIONING_CHECK_ACTION | Broadcast Action: Trigger the polling of provisioning service to download the latest settings. | "android.intent.action.PROVISIONING_CHECK" | |
| String | RUN_ACTION | Activity Action: Run the data, whatever that means. | "android.intent.action.RUN" | |
| String | SAMPLE_CODE_CATEGORY | To be used as an sample code example (not part of the normal user experience). | "android.intent.category.SAMPLE_CODE" | |
| String | SCREEN_OFF_ACTION | Broadcast Action: Sent after the screen turns off. | "android.intent.action.SCREEN_OFF" | |
| String | SCREEN_ON_ACTION | Broadcast Action: Sent after the screen turns on. | "android.intent.action.SCREEN_ON" | |
| String | SEARCH_ACTION | Activity Action: Perform a search. | "android.intent.action.SEARCH" | |
| String | SELECTED_ALTERNATIVE_CATEGORY | Set if the activity should be considered as an alternative selection action to the data the user has currently selected. | "android.intent.category.SELECTED_ALTERNATIVE" | |
| String | SENDTO_ACTION | Activity Action: Send a message to someone specified by the data. | "android.intent.action.SENDTO" | |
| String | SEND_ACTION | Activity Action: Deliver some data to someone else. | "android.intent.action.SEND" | |
| String | SERVICE_STATE_CHANGED_ACTION | Broadcast Action: The phone service state has changed. | "android.intent.action.SERVICE_STATE" | |
| String | SETTINGS_ACTION | Activity Action: Show system settings
Input: Nothing. | "android.intent.action.SETTINGS" | |
| String | SIGNAL_STRENGTH_CHANGED_ACTION | Broadcast Action: The phone's signal strength has changed. | "android.intent.action.SIG_STR" | |
| String | SIM_STATE_CHANGED_ACTION | Broadcast Action: The sim card state has changed. | "android.intent.action.SIM_STATE_CHANGED" | |
| int | SINGLE_TOP_LAUNCH | If set, the activity will not be launched if it is already running at the top of the history stack. | 2 | 0x00000002 |
| String | STREAM_EXTRA | A content: URI holding a stream of data associated with the Intent, used with SEND_ACTION to supply the data being sent. | "android.intent.extra.STREAM" | |
| String | SYNC_ACTION | Activity Action: Perform a data synchronization. | "android.intent.action.SYNC" | |
| String | TAB_CATEGORY | Intended to be used as a tab inside of an containing TabActivity. | "android.intent.category.TAB" | |
| String | TEMPLATE_EXTRA | The initial data to place in a newly created record. | "android.intent.extra.TEMPLATE" | |
| String | TEST_CATEGORY | To be used as a test (not part of the normal user experience). | "android.intent.category.TEST" | |
| String | TEXT_EXTRA | A constant string that is associated with the Intent, used with SEND_ACTION to supply the literal data to be sent. | "android.intent.extra.TEXT" | |
| String | TIMEZONE_CHANGED_ACTION | Broadcast Action: The timezone has changed. | "android.intent.action.TIMEZONE_CHANGED" | |
| String | TIME_CHANGED_ACTION | Broadcast Action: The time was set. | "android.intent.action.TIME_SET" | |
| String | TIME_TICK_ACTION | Broadcast Action: The current time has changed. | "android.intent.action.TIME_TICK" | |
| String | UMS_CONNECTED_ACTION | Broadcast Action: The device has entered USB Mass Storage mode. | "android.intent.action.UMS_CONNECTED" | |
| String | UMS_DISCONNECTED_ACTION | Broadcast Action: The device has exited USB Mass Storage mode. | "android.intent.action.UMS_DISCONNECTED" | |
| String | UNIT_TEST_CATEGORY | To be used as a unit test (run through the Test Harness). | "android.intent.category.UNIT_TEST" | |
| String | VIEW_ACTION | Activity Action: Display the data to the user. | "android.intent.action.VIEW" | |
| String | WALLPAPER_CATEGORY | This activity is able to configure the wallpaper for the device | "android.intent.category.WALLPAPER" | |
| String | WALLPAPER_CHANGED_ACTION | Broadcast Action: The current system wallpaper has changed. | "android.intent.action.WALLPAPER_CHANGED" | |
| String | WALLPAPER_SETTINGS_ACTION | Activity Action: Show settings for choosing wallpaper
Input: Nothing. | "android.intent.action.WALLPAPER_SETTINGS" | |
| String | WEB_SEARCH_ACTION | Activity Action: Perform a web search. | "android.intent.action.WEB_SEARCH" | |
[edit] Public Constructors
| Intent () | |||||
| Create an empty intent. | |||||
| Intent (Intent o) | |||||
| Copy constructor. | |||||
| Intent (String action) | |||||
| Create an intent with a given action. | |||||
| Intent (String action, Uri uri) | |||||
| Create an intent with a given action and for a given data url. | |||||
| )">Intent (Context packageContext, Class cls) | |||||
| Create an intent for a specific component. | |||||
| )">Intent (String action, Uri uri, Context packageContext, Class cls) | |||||
| Create an intent for a specific component with a specified action and data. | |||||
[edit] Public Methods
| Intent | addCategory (String category) | ||||
| Add a new category to the intent. | |||||
| Intent | addLaunchFlags (int flags) | ||||
| Add additional launch flags to the intent (or with existing flags value). | |||||
| boolean | filterEquals (Intent other) | ||||
| Determine if two intents are the same for the purposes of intent resolution (filtering). | |||||
| int | filterHashCode () | ||||
| Generate hash code that matches semantics of filterEquals(). | |||||
| String | getAction () | ||||
| Retrieve the general action to be performed, such as VIEW_ACTION. | |||||
| boolean | getBooleanExtra (String name, boolean defaultValue) | ||||
| Retrieve extended data from the intent. | |||||
| Bundle | getBundleExtra (String name) | ||||
| Retrieve extended data from the intent. | |||||
| byte | getByteExtra (String name, byte defaultValue) | ||||
| Retrieve extended data from the intent. | |||||
| Set | getCategories () | ||||
| Return the set of all categories in the intent. | |||||
| char | getCharExtra (String name, char defaultValue) | ||||
| Retrieve extended data from the intent. | |||||
| CharSequence | getCharSequenceExtra (String name) | ||||
| Retrieve extended data from the intent. | |||||
| ComponentName | getComponent () | ||||
| Retrieve the concrete component associated with the intent. | |||||
| Uri | getData () | ||||
| Retrieve data this intent is operating on. | |||||
| double | getDoubleExtra (String name, double defaultValue) | ||||
| Retrieve extended data from the intent. | |||||
| Object | getExtra (String name, Object defaultValue) | ||||
| Retrieve extended data from the intent. | |||||
| Object | getExtra (String name) | ||||
| Retrieve extended data from the intent. | |||||
| Bundle | getExtras () | ||||
| Retrieves a map of extended data from the intent. | |||||
| float | getFloatExtra (String name, float defaultValue) | ||||
| Retrieve extended data from the intent. | |||||
| IBinder | getIBinderExtra (String name) | ||||
| Retrieve extended data from the intent. | |||||
| int | getIntExtra (String name, int defaultValue) | ||||
| Retrieve extended data from the intent. | |||||
| static | Intent | getIntent (String uri) | |||
| Create an intent from a URI. | |||||
| int | getLaunchFlags () | ||||
| Retrieve any special launch flags associated with this intent. | |||||
| long | getLongExtra (String name, long defaultValue) | ||||
| Retrieve extended data from the intent. | |||||
| Parcelable[ ] | getParcelableArrayExtra (String name) | ||||
| Retrieve extended data from the intent. | |||||
| Parcelable | getParcelableExtra (String name) | ||||
| Retrieve extended data from the intent. | |||||
| String | getScheme () | ||||
| Return the scheme portion of the intent's data. | |||||
| Serializable | getSerializableExtra (String name) | ||||
| Retrieve extended data from the intent. | |||||
| short | getShortExtra (String name, short defaultValue) | ||||
| Retrieve extended data from the intent. | |||||
| String | getStringExtra (String name) | ||||
| Retrieve extended data from the intent. | |||||
| String | getType () | ||||
| Retrieve any explicit MIME type included in the intent. | |||||
| boolean | hasCategory (String category) | ||||
| Check if an category exists in the intent. | |||||
| boolean | hasExtra (String name) | ||||
| Returns true if an extra value is associated with the given name. | |||||
| Intent | putExtra (String name, float value) | ||||
| Add extended data to the intent. | |||||
| Intent | putExtra (String name, short value) | ||||
| Add extended data to the intent. | |||||
| Intent | putExtra (String name, Parcelable value) | ||||
| Add extended data to the intent. | |||||
| Intent | putExtra (String name, long value) | ||||
| Add extended data to the intent. | |||||
| Intent | putExtra (String name, boolean value) | ||||
| Add extended data to the intent. | |||||
| Intent | putExtra (String name, double value) | ||||
| Add extended data to the intent. | |||||
| Intent | putExtra (String name, IBinder value) | ||||
| Add extended data to the intent. | |||||
| Intent | putExtra (String name, String value) | ||||
| Add extended data to the intent. | |||||
| Intent | putExtra (String name, Serializable value) | ||||
| Add extended data to the intent. | |||||
| Intent | putExtra (String name, Bundle value) | ||||
| Add extended data to the intent. | |||||
| Intent | putExtra (String name, Parcelable[ ] value) | ||||
| Add extended data to the intent. | |||||
| Intent | putExtra (String name, char value) | ||||
| Add extended data to the intent. | |||||
| Intent | putExtra (String name, CharSequence value) | ||||
| Add extended data to the intent. | |||||
| Intent | putExtra (String name, byte value) | ||||
| Add extended data to the intent. | |||||
| Intent | putExtra (String name, int value) | ||||
| Add extended data to the intent. | |||||
| void | putExtras (Intent src) | ||||
| Copy all extras in 'src' in to this intent. | |||||
| void | putExtras (Bundle extras) | ||||
| Add a set of extended data to the intent. | |||||
| void | readFromParcel (Parcel in) | ||||
| void | removeCategory (String category) | ||||
| Remove an category from an intent. | |||||
| void | removeExtra (String name) | ||||
| Remove extended data from the intent. | |||||
| ComponentName | resolveActivity (PackageManager pm) | ||||
| Return the Activity component that should be used to handle this intent. | |||||
| ActivityInfo | resolveActivityInfo (PackageManager pm) | ||||
| Resolve the Intent into an ActivityInfo describing the activity that should execute the intent. | |||||
| String | resolveType (ContentResolver resolver) | ||||
| Return the MIME data type of this intent. | |||||
| String | resolveType (Context context) | ||||
| Return the MIME data type of this intent. | |||||
| String | resolveTypeIfNeeded (ContentResolver resolver) | ||||
| Return the MIME data type of this intent, only if it will be needed for intent resolution. | |||||
| Intent | setAction (String action) | ||||
| Set the general action to be performed. | |||||
| Intent | )">setClass (Context packageContext, Class cls) | ||||
| Convenience for calling setComponent(ComponentName) with the name returned by a Class object. | |||||
| Intent | setClassName (String packageName, String className) | ||||
| Convenience for calling setComponent(ComponentName) with an explicit application package name and class name. | |||||
| Intent | setClassName (Context packageContext, String className) | ||||
| Convenience for calling setComponent(ComponentName) with an explicit class name. | |||||
| Intent | setComponent (ComponentName component) | ||||
| (Usually optional) Explicitly set the component to handle the intent. | |||||
| Intent | setData (Uri data) | ||||
| Set the data this intent is operating on. | |||||
| Intent | setDataAndType (Uri data, String type) | ||||
| (Usually optional) Set the data for the intent along with an explicit MIME data type. | |||||
| void | setExtrasClassLoader (ClassLoader loader) | ||||
| Sets the ClassLoader that will be used when unmarshalling any Parcelable values from the extras of this Intent. | |||||
| Intent | setLaunchFlags (int flags) | ||||
| Set special launch flags controlling how this intent is handled. | |||||
| Intent | setType (String type) | ||||
| Set an explicit MIME data type. | |||||
| String | toString () | ||||
| Answers a string containing a concise, human-readable description of the receiver. | |||||
| String | toURI () | ||||
| void | writeToParcel (Parcel out) | ||||
[edit] Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait[edit] Methods inherited from interface android.os.Parcelable
[edit] Details
[edit] Constants
[edit] public static final String ADD_SHORTCUT_ACTION
Activity Action: Add a new shortcut to the system.
Input: getExtra(String) field INTENT_EXTRA is an Intent describing the shortcut to be added, LABEL_EXTRA is an optional label to use for the shortcut.
Output: nothing. Constant Value: "android.intent.action.ADD_SHORTCUT"
[edit] public static final String ALL_APPS_ACTION
Activity Action: List all available applications
Input: Nothing.
Output: nothing. Constant Value: "android.intent.action.ALL_APPS"
[edit] public static final String ALTERNATIVE_CATEGORY
Set if the activity should be considered as an alternative action to the data the user is currently viewing. See also SELECTED_ALTERNATIVE_CATEGORY for an alternative action that applies to the selection in a list of items.
Supporting this category means that you would like your activity to be displayed in the set of alternative things the user can do, usually as part of the current activity's options menu. You will usually want to include a specific label in the <intent-filter> of this action describing to the user what it does.
The action of IntentFilter with this category is important in that it describes the specific action the target will perform. This generally should not be a generic action (such as VIEW_ACTION, but rather a specific name such as "com.google.android.camera.action.CROP. Only one alternative of any particular action will be shown to the user, so using a specific action like this makes sure that your alternative will be displayed while also allowing other applications to provide their own overrides of that particular action. Constant Value: "android.intent.category.ALTERNATIVE"
[edit] public static final String ANSWER_ACTION
Activity Action: Handle an incoming phone call.
Input: nothing.
Output: nothing. Constant Value: "android.intent.action.ANSWER"
[edit] public static final String BATTERY_CHANGED_ACTION
Broadcast Action: The charging state, or charge level of the battery has changed.
Note: Because this broadcast is sent often, you should not register for it in your package. Constant Value: "android.intent.action.BATTERY_CHANGED"
[edit] public static final String BOOT_COMPLETED_ACTION
Broadcast Action: This is broadcast once, after the system has finished booting. It can be used to perform application-specific initialization, such as installing alarms. You must hold the RECEIVE_BOOT_COMPLETED permission in order to receive this broadcast. Constant Value: "android.intent.action.BOOT_COMPLETED"
[edit] public static final String BROWSABLE_CATEGORY
Activities that can be safely invoked from a browser must support this category. For example, if the user is viewing a web page or an e-mail and clicks on a link in the text, the Intent generated execute that link will require the BROWSABLE category, so that only activities supporting this category will be considered as possible actions. By supporting this category, you are promising that there is nothing damaging (without user intervention) that can happen by invoking any matching Intent. Constant Value: "android.intent.category.BROWSABLE"
[edit] public static final String BUG_REPORT_ACTION
Activity Action: Show activity for reporting a bug.
Input: Nothing.
Output: Nothing. Constant Value: "android.intent.action.BUG_REPORT"
[edit] public static final String CALL_ACTION
Activity Action: Perform a call to someone specified by the data.
Input: If nothing, an empty dialer is started; else getData() is URI of a phone number to be dialed or a tel: URI of an explicit phone number.
Output: nothing.
Note: there will be restrictions on which applications can initiate a call; most applications should use the DIAL_ACTION. Constant Value: "android.intent.action.CALL"
[edit] public static final String CALL_FORWARDING_STATE_CHANGED_ACTION
Broadcast Action: The phone's voice call forwarding (unconditional) state has changed. The intent will have the following extra values:
- phoneName - A string version of the phone name.
- cff - A boolean value where true indica