跳转的方式:
Intent intent = new Intent();
//添加意图的动作
intent.setAction(Intent.ACTION_CALL);
//添加意图的数据
//url: 统一资源标识符 uri: 统一资源定位符
intent.setData(Uri.parse("tel:"+number));
//实现这个意图
startActivity(intent);
通过action实现我们的跳转, 设置数据 data 来设置我们传递的数据。
java.lang.Object | |
↳ | android.content.Intent |
An intent is an abstract description of an operation to be performed. It can be used withstartActivity
to launch anActivity
,broadcastIntent
to send it to any interested BroadcastReceiver
components, andstartService(Intent)
orbindService(Intent, ServiceConnection, int)
to communicate with a background Service
.
一个intent就是一个执行动作的说明,
它的作用可以 开启一个activity 或者发送广播信息 还有就是可以开启或者绑定服务。
主要用在activity之间
Intent Structure
intnet的结构:action -- The general action to be performed, such asACTION_VIEW
,ACTION_EDIT
,ACTION_MAIN
, etc.
设置动作 上面的是系统的。
data -- The data to operate on, such as a person record in the contacts database, expressed as aUri
.
-
ACTION_VIEW
content://contacts/people/1 -- Display information about the person whose identifier is "1". -
ACTION_DIAL
content://contacts/people/1 -- Display the phone dialer with the person filled in. -
ACTION_VIEW
tel:123 -- Display the phone dialer with the given number filled in. Note how the VIEW action does what what is considered the most reasonable thing for a particular URI. -
ACTION_DIAL
tel:123 -- Display the phone dialer with the given number filled in. -
ACTION_EDIT
content://contacts/people/1 -- Edit information about the person whose identifier is "1". -
ACTION_VIEW
content://contacts/people/ -- 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 {ACTION_VIEW
content://contacts/N } being used to start an activity to display that person.
category -- Gives additional information about the action to execute.
For example, CATEGORY_LAUNCHER
means it should appear in the Launcher as a top-level application,
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.
extras -- This is a Bundle
of any additional information. This can be used to provide extended information to the component.
ACTION_MAIN
with categoryCATEGORY_HOME
-- Launch the home screen.
Explicit Intents have specified a component (viasetComponent(ComponentName)
orsetClass(Context, Class)
), which provides the exact class to be run.
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.
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 ACTION_MAIN
and ACTION_EDIT
.
ACTION_MAIN
ACTION_VIEW
ACTION_ATTACH_DATA
ACTION_EDIT
ACTION_PICK
ACTION_CHOOSER
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
Standard Broadcast Actions
These are the current standard actions that Intent defines for receiving broadcasts (usually through registerReceiver(BroadcastReceiver, IntentFilter)
or a <receiver> tag in a manifest).
ACTION_TIME_TICK
ACTION_TIME_CHANGED
ACTION_TIMEZONE_CHANGED
ACTION_BOOT_COMPLETED
ACTION_PACKAGE_ADDED
ACTION_PACKAGE_CHANGED
ACTION_PACKAGE_REMOVED
ACTION_PACKAGE_RESTARTED
ACTION_PACKAGE_DATA_CLEARED
ACTION_UID_REMOVED
ACTION_BATTERY_CHANGED
ACTION_POWER_CONNECTED
ACTION_POWER_DISCONNECTED
ACTION_SHUTDOWN
Standard Categories
These are the current standard categories that can be used to further clarify an Intent via addCategory(String)
.
CATEGORY_DEFAULT
CATEGORY_BROWSABLE
CATEGORY_TAB
CATEGORY_ALTERNATIVE
CATEGORY_SELECTED_ALTERNATIVE
CATEGORY_LAUNCHER
CATEGORY_INFO
CATEGORY_HOME
CATEGORY_PREFERENCE
CATEGORY_TEST
CATEGORY_CAR_DOCK
CATEGORY_DESK_DOCK
CATEGORY_LE_DESK_DOCK
CATEGORY_HE_DESK_DOCK
CATEGORY_CAR_MODE
CATEGORY_APP_MARKET
Standard Extra Data
These are the current standard fields that can be used as extra data via putExtra(String, Bundle)
.
EXTRA_ALARM_COUNT
EXTRA_BCC
EXTRA_CC
EXTRA_CHANGED_COMPONENT_NAME
EXTRA_DATA_REMOVED
EXTRA_DOCK_STATE
EXTRA_DOCK_STATE_HE_DESK
EXTRA_DOCK_STATE_LE_DESK
EXTRA_DOCK_STATE_CAR
EXTRA_DOCK_STATE_DESK
EXTRA_DOCK_STATE_UNDOCKED
EXTRA_DONT_KILL_APP
EXTRA_EMAIL
EXTRA_INITIAL_INTENTS
EXTRA_INTENT
EXTRA_KEY_EVENT
EXTRA_ORIGINATING_URI
EXTRA_PHONE_NUMBER
EXTRA_REFERRER
EXTRA_REMOTE_INTENT_TOKEN
EXTRA_REPLACING
EXTRA_SHORTCUT_ICON
EXTRA_SHORTCUT_ICON_RESOURCE
EXTRA_SHORTCUT_INTENT
EXTRA_STREAM
EXTRA_SHORTCUT_NAME
EXTRA_SUBJECT
EXTRA_TEMPLATE
EXTRA_TEXT
EXTRA_TITLE
EXTRA_UID
Intent()
Intent(
String action,
Uri uri)
Create an intent with a given action and for a given data url.
|
Intent( Context packageContext, Class<?> cls)
Parameters
packageContext | A Context of the application package implementing this class. |
---|---|
cls | The component class that is to be used for the intent. |
Intent( String action, Uri uri, Context packageContext, Class<?> cls)
Parameters
action | The Intent action, such as ACTION_VIEW. |
---|---|
uri | The Intent data URI. |
packageContext | A Context of the application package implementing this class. |
cls | The component class that is to be used for the intent. |
addCategory( String category)
Parameters
category | The desired category. This can be either one of the predefined Intent categories, or a custom category in your own namespace. |
---|
Returns
- Returns the same Intent object, for chaining multiple calls into a single statement.
addFlags(int flags)
Parameters
flags | The new flags to set. |
---|
Returns
- Returns the same Intent object, for chaining multiple calls into a single statement.
ACTION_VIEW
.
public boolean[] getBooleanArrayExtra (String name)
Retrieve extended data from the intent.
Parameters
name | The name of the desired item. |
---|
Returns
- the value of an item that previously added with putExtra() or null if no boolean array value was found.
See Also
public boolean getBooleanExtra (String name, boolean defaultValue)
Retrieve extended data from the intent.
Parameters
name | The name of the desired item. |
---|---|
defaultValue | the value to be returned if no value of the desired type is stored with the given name. |
Returns
- the value of an item that previously added with putExtra() or the default value if none was found.
See Also
public Bundle getBundleExtra (String name)
Retrieve extended data from the intent.
Parameters
name | The name of the desired item. |
---|
Returns
- the value of an item that previously added with putExtra() or null if no Bundle value was found.
See Also
public byte[] getByteArrayExtra (String name)
Retrieve extended data from the intent.
Parameters
name | The name of the desired item. |
---|
Returns
- the value of an item that previously added with putExtra() or null if no byte array value was found.
See Also
public byte getByteExtra (String name, byte defaultValue)
Retrieve extended data from the intent.
Parameters
name | The name of the desired item. |
---|---|
defaultValue | the value to be returned if no value of the desired type is stored with the given name. |
Returns
- the value of an item that previously added with putExtra() or the default value if none was found.
See Also
public Set<String> getCategories ()
Return the set of all categories in the intent. If there are no categories, returns NULL.
Returns
- The set of categories you can examine. Do not modify!
public char[] getCharArrayExtra (String name)
Retrieve extended data from the intent.
Parameters
name | The name of the desired item. |
---|
Returns
- the value of an item that previously added with putExtra() or null if no char array value was found.
See Also
public char getCharExtra (String name, char defaultValue)
Retrieve extended data from the intent.
Parameters
name | The name of the desired item. |
---|---|
defaultValue | the value to be returned if no value of the desired type is stored with the given name. |
Returns
- the value of an item that previously added with putExtra() or the default value if none was found.
See Also
public CharSequence[] getCharSequenceArrayExtra (String name)
Retrieve extended data from the intent.
Parameters
name | The name of the desired item. |
---|
Returns
- the value of an item that previously added with putExtra() or null if no CharSequence array value was found.
See Also
public ArrayList<CharSequence> getCharSequenceArrayListExtra (String name)
Retrieve extended data from the intent.
Parameters
name | The name of the desired item. |
---|
Returns
- the value of an item that previously added with putExtra() or null if no ArrayList value was found.
public CharSequence getCharSequenceExtra (String name)
Retrieve extended data from the intent.
Parameters
name | The name of the desired item. |
---|
Returns
- the value of an item that previously added with putExtra() or null if no CharSequence value was found.
See Also
public ClipData getClipData ()
Return the ClipData
associated with this Intent. If there is none, returns null. See setClipData(ClipData)
for more information.
See Also
public ComponentName getComponent ()
Retrieve the concrete component associated with the intent. When receiving an intent, this is the component that was found to best handle it (that is, yourself) and will always be non-null; in all other cases it will be null unless explicitly set.
Returns
- The name of the application component to handle the intent.
public Uri getData ()
Retrieve data this intent is operating on. This URI specifies the name of the data; often it uses the content: scheme, specifying data in a content provider. Other schemes may be handled by specific activities, such as http: by the web browser.
Returns
- The URI of the data this intent is targeting or null.
See Also
public String getDataString ()
The same as getData()
, but returns the URI as an encoded String.
public double[] getDoubleArrayExtra (String name)
Retrieve extended data from the intent.
Parameters
name | The name of the desired item. |
---|
Returns
- the value of an item that previously added with putExtra() or null if no double array value was found.
See Also
public double getDoubleExtra (String name, double defaultValue)
Retrieve extended data from the intent.
Parameters
name | The name of the desired item. |
---|---|
defaultValue | the value to be returned if no value of the desired type is stored with the given name. |
Returns
- the value of an item that previously added with putExtra() or the default value if none was found.
See Also
public Bundle getExtras ()
Retrieves a map of extended data from the intent.
Returns
- the map of all extras previously added with putExtra(), or null if none have been added.
public int getFlags ()
Retrieve any special flags associated with this intent. You will normally just set them with setFlags(int)
and let the system take the appropriate action with them.
Returns
- int The currently set flags.
See Also
public float[] getFloatArrayExtra (String name)
Retrieve extended data from the intent.
Parameters
name | The name of the desired item. |
---|
Returns
- the value of an item that previously added with putExtra() or null if no float array value was found.
See Also
public float getFloatExtra (String name, float defaultValue)
Retrieve extended data from the intent.
Parameters
name | The name of the desired item. |
---|---|
defaultValue | the value to be returned if no value of the desired type is stored with the given name. |
Returns
- the value of an item that previously added with putExtra(), or the default value if no such item is present
See Also
public int[] getIntArrayExtra (String name)
Retrieve extended data from the intent.
Parameters
name | The name of the desired item. |
---|
Returns
- the value of an item that previously added with putExtra() or null if no int array value was found.
See Also
public int getIntExtra (String name, int defaultValue)
Retrieve extended data from the intent.
Parameters
name | The name of the desired item. |
---|---|
defaultValue | the value to be returned if no value of the desired type is stored with the given name. |
Returns
- the value of an item that previously added with putExtra() or the default value if none was found.
See Also
public ArrayList<Integer> getIntegerArrayListExtra (String name)
Retrieve extended data from the intent.
Parameters
name | The name of the desired item. |
---|
Returns
- the value of an item that previously added with putExtra() or null if no ArrayList value was found.
public static Intent getIntent (String uri)
This method was deprecated in API level 4.
Use parseUri(String, int)
instead.
Call parseUri(String, int)
with 0 flags.
Throws
URISyntaxException |
---|
public long[] getLongArrayExtra (String name)
Retrieve extended data from the intent.
Parameters
name | The name of the desired item. |
---|
Returns
- the value of an item that previously added with putExtra() or null if no long array value was found.
See Also
public long getLongExtra (String name, long defaultValue)
Retrieve extended data from the intent.
Parameters
name | The name of the desired item. |
---|---|
defaultValue | the value to be returned if no value of the desired type is stored with the given name. |
Returns
- the value of an item that previously added with putExtra() or the default value if none was found.
See Also
public String getPackage ()
Retrieve the application package name this Intent is limited to. When resolving an Intent, if non-null this limits the resolution to only components in the given application package.
Returns
- The name of the application package for the Intent.
public Parcelable[] getParcelableArrayExtra (String name)
Retrieve extended data from the intent.
Parameters
name | The name of the desired item. |
---|
Returns
- the value of an item that previously added with putExtra() or null if no Parcelable[] value was found.
See Also
public ArrayList<T> getParcelableArrayListExtra (String name)
Retrieve extended data from the intent.
Parameters
name | The name of the desired item. |
---|
Returns
- the value of an item that previously added with putExtra() or null if no ArrayList value was found.
public T getParcelableExtra (String name)
Retrieve extended data from the intent.
Parameters
name | The name of the desired item. |
---|
Returns
- the value of an item that previously added with putExtra() or null if no Parcelable value was found.
See Also
public Serializable getSerializableExtra (String name)
Retrieve extended data from the intent.
Parameters
name | The name of the desired item. |
---|
Returns
- the value of an item that previously added with putExtra() or null if no Serializable value was found.
See Also
public short[] getShortArrayExtra (String name)
Retrieve extended data from the intent.
Parameters
name | The name of the desired item. |
---|
Returns
- the value of an item that previously added with putExtra() or null if no short array value was found.
See Also
public short getShortExtra (String name, short defaultValue)
Retrieve extended data from the intent.
Parameters
name | The name of the desired item. |
---|---|
defaultValue | the value to be returned if no value of the desired type is stored with the given name. |
Returns
- the value of an item that previously added with putExtra() or the default value if none was found.
See Also
public String[] getStringArrayExtra (String name)
Retrieve extended data from the intent.
Parameters
name | The name of the desired item. |
---|
Returns
- the value of an item that previously added with putExtra() or null if no String array value was found.
See Also
public ArrayList<String> getStringArrayListExtra (String name)
Retrieve extended data from the intent.
Parameters
name | The name of the desired item. |
---|
Returns
- the value of an item that previously added with putExtra() or null if no ArrayList value was found.
public String getStringExtra (String name)
Retrieve extended data from the intent.
Parameters
name | The name of the desired item. |
---|
Returns
- the value of an item that previously added with putExtra() or null if no String value was found.
See Also
public static Intent parseIntent (Resources resources, XmlPullParser parser, AttributeSet attrs)
Parses the "intent" element (and its children) from XML and instantiates an Intent object. The given XML parser should be located at the tag where parsing should start (often named "intent"), from which the basic action, data, type, and package and class name will be retrieved. The function will then parse in to any child elements, looking for tags to add categories and to attach extra data to the intent.
Parameters
resources | The Resources to use when inflating resources. |
---|---|
parser | The XML parser pointing at an "intent" tag. |
attrs | The AttributeSet interface for retrieving extended attribute data at the current parser location. |
Returns
- An Intent object matching the XML data.
Throws
XmlPullParserException | If there was an XML parsing error. |
---|---|
IOException | If there was an I/O error. |
public static Intent parseUri (String uri, int flags)
Create an intent from a URI. This URI may encode the action, category, and other intent fields, if it was returned by toUri(int)
. If the Intent was not generate by toUri(), its data will be the entire URI and its action will be ACTION_VIEW.
The URI given here must not be relative -- that is, it must include the scheme and full path.
Parameters
uri | The URI to turn into an Intent. |
---|---|
flags | Additional processing flags. Either 0 or URI_INTENT_SCHEME . |
Returns
- Intent The newly created Intent object.
Throws
URISyntaxException | Throws URISyntaxError if the basic URI syntax it bad (as parsed by the Uri class) or the Intent data within the URI is invalid. |
---|
See Also
public Intent putCharSequenceArrayListExtra (String name, ArrayList<CharSequence> value)
Add extended data to the intent. The name must include a package prefix, for example the app com.android.contacts would use names like "com.android.contacts.ShowAll".
Parameters
name | The name of the extra data, with package prefix. |
---|---|
value | The ArrayList data value. |
Returns
- Returns the same Intent object, for chaining multiple calls into a single statement.
public Intent putExtra (String name, double[] value)
Add extended data to the intent. The name must include a package prefix, for example the app com.android.contacts would use names like "com.android.contacts.ShowAll".
Parameters
name | The name of the extra data, with package prefix. |
---|---|
value | The double array data value. |
Returns
- Returns the same Intent object, for chaining multiple calls into a single statement.
public Intent putExtra (String name, int value)
Add extended data to the intent. The name must include a package prefix, for example the app com.android.contacts would use names like "com.android.contacts.ShowAll".
Parameters
name | The name of the extra data, with package prefix. |
---|---|
value | The integer data value. |
Returns
- Returns the same Intent object, for chaining multiple calls into a single statement.
public Intent putExtra (String name, CharSequence value)
Add extended data to the intent. The name must include a package prefix, for example the app com.android.contacts would use names like "com.android.contacts.ShowAll".
Parameters
name | The name of the extra data, with package prefix. |
---|---|
value | The CharSequence data value. |
Returns
- Returns the same Intent object, for chaining multiple calls into a single statement.
public Intent putExtra (String name, char value)
Add extended data to the intent. The name must include a package prefix, for example the app com.android.contacts would use names like "com.android.contacts.ShowAll".
Parameters
name | The name of the extra data, with package prefix. |
---|---|
value | The char data value. |
Returns
- Returns the same Intent object, for chaining multiple calls into a single statement.
public Intent putExtra (String name, Bundle value)
Add extended data to the intent. The name must include a package prefix, for example the app com.android.contacts would use names like "com.android.contacts.ShowAll".
Parameters
name | The name of the extra data, with package prefix. |
---|---|
value | The Bundle data value. |
Returns
- Returns the same Intent object, for chaining multiple calls into a single statement.
public Intent putExtra (String name, Parcelable[] value)
Add extended data to the intent. The name must include a package prefix, for example the app com.android.contacts would use names like "com.android.contacts.ShowAll".
Parameters
name | The name of the extra data, with package prefix. |
---|---|
value | The Parcelable[] data value. |
Returns
- Returns the same Intent object, for chaining multiple calls into a single statement.
public Intent putExtra (String name, Serializable value)
Add extended data to the intent. The name must include a package prefix, for example the app com.android.contacts would use names like "com.android.contacts.ShowAll".
Parameters
name | The name of the extra data, with package prefix. |
---|---|
value | The Serializable data value. |
Returns
- Returns the same Intent object, for chaining multiple calls into a single statement.
public Intent putExtra (String name, int[] value)
Add extended data to the intent. The name must include a package prefix, for example the app com.android.contacts would use names like "com.android.contacts.ShowAll".
Parameters
name | The name of the extra data, with package prefix. |
---|---|
value | The int array data value. |
Returns
- Returns the same Intent object, for chaining multiple calls into a single statement.
public Intent putExtra (String name, float value)
Add extended data to the intent. The name must include a package prefix, for example the app com.android.contacts would use names like "com.android.contacts.ShowAll".
Parameters
name | The name of the extra data, with package prefix. |
---|---|
value | The float data value. |
Returns
- Returns the same Intent object, for chaining multiple calls into a single statement.
public Intent putExtra (String name, byte[] value)
Add extended data to the intent. The name must include a package prefix, for example the app com.android.contacts would use names like "com.android.contacts.ShowAll".
Parameters
name | The name of the extra data, with package prefix. |
---|---|
value | The byte array data value. |
Returns
- Returns the same Intent object, for chaining multiple calls into a single statement.
public Intent putExtra (String name, long[] value)
Add extended data to the intent. The name must include a package prefix, for example the app com.android.contacts would use names like "com.android.contacts.ShowAll".
Parameters
name | The name of the extra data, with package prefix. |
---|---|
value | The byte array data value. |
Returns
- Returns the same Intent object, for chaining multiple calls into a single statement.
public Intent putExtra (String name, Parcelable value)
Add extended data to the intent. The name must include a package prefix, for example the app com.android.contacts would use names like "com.android.contacts.ShowAll".
Parameters
name | The name of the extra data, with package prefix. |
---|---|
value | The Parcelable data value. |
Returns
- Returns the same Intent object, for chaining multiple calls into a single statement.
public Intent putExtra (String name, float[] value)
Add extended data to the intent. The name must include a package prefix, for example the app com.android.contacts would use names like "com.android.contacts.ShowAll".
Parameters
name | The name of the extra data, with package prefix. |
---|---|
value | The float array data value. |
Returns
- Returns the same Intent object, for chaining multiple calls into a single statement.
public Intent putExtra (String name, long value)
Add extended data to the intent. The name must include a package prefix, for example the app com.android.contacts would use names like "com.android.contacts.ShowAll".
Parameters
name | The name of the extra data, with package prefix. |
---|---|
value | The long data value. |
Returns
- Returns the same Intent object, for chaining multiple calls into a single statement.
public Intent putExtra (String name, String[] value)
Add extended data to the intent. The name must include a package prefix, for example the app com.android.contacts would use names like "com.android.contacts.ShowAll".
Parameters
name | The name of the extra data, with package prefix. |
---|---|
value | The String array data value. |
Returns
- Returns the same Intent object, for chaining multiple calls into a single statement.
public Intent putExtra (String name, boolean value)
Add extended data to the intent. The name must include a package prefix, for example the app com.android.contacts would use names like "com.android.contacts.ShowAll".
Parameters
name | The name of the extra data, with package prefix. |
---|---|
value | The boolean data value. |
Returns
- Returns the same Intent object, for chaining multiple calls into a single statement.
public Intent putExtra (String name, boolean[] value)
Add extended data to the intent. The name must include a package prefix, for example the app com.android.contacts would use names like "com.android.contacts.ShowAll".
Parameters
name | The name of the extra data, with package prefix. |
---|---|
value | The boolean array data value. |
Returns
- Returns the same Intent object, for chaining multiple calls into a single statement.
public Intent putExtra (String name, short value)
Add extended data to the intent. The name must include a package prefix, for example the app com.android.contacts would use names like "com.android.contacts.ShowAll".
Parameters
name | The name of the extra data, with package prefix. |
---|---|
value | The short data value. |
Returns
- Returns the same Intent object, for chaining multiple calls into a single statement.
public Intent putExtra (String name, double value)
Add extended data to the intent. The name must include a package prefix, for example the app com.android.contacts would use names like "com.android.contacts.ShowAll".
Parameters
name | The name of the extra data, with package prefix. |
---|---|
value | The double data value. |
Returns
- Returns the same Intent object, for chaining multiple calls into a single statement.
public Intent putExtra (String name, short[] value)
Add extended data to the intent. The name must include a package prefix, for example the app com.android.contacts would use names like "com.android.contacts.ShowAll".
Parameters
name | The name of the extra data, with package prefix. |
---|---|
value | The short array data value. |
Returns
- Returns the same Intent object, for chaining multiple calls into a single statement.
public Intent putExtra (String name, String value)
Add extended data to the intent. The name must include a package prefix, for example the app com.android.contacts would use names like "com.android.contacts.ShowAll".
Parameters
name | The name of the extra data, with package prefix. |
---|---|
value | The String data value. |
Returns
- Returns the same Intent object, for chaining multiple calls into a single statement.
public Intent putExtra (String name, byte value)
Add extended data to the intent. The name must include a package prefix, for example the app com.android.contacts would use names like "com.android.contacts.ShowAll".
Parameters
name | The name of the extra data, with package prefix. |
---|---|
value | The byte data value. |
Returns
- Returns the same Intent object, for chaining multiple calls into a single statement.
public Intent putExtra (String name, char[] value)
Add extended data to the intent. The name must include a package prefix, for example the app com.android.contacts would use names like "com.android.contacts.ShowAll".
Parameters
name | The name of the extra data, with package prefix. |
---|---|
value | The char array data value. |
Returns
- Returns the same Intent object, for chaining multiple calls into a single statement.
public Intent putExtra (String name, CharSequence[] value)
Add extended data to the intent. The name must include a package prefix, for example the app com.android.contacts would use names like "com.android.contacts.ShowAll".
Parameters
name | The name of the extra data, with package prefix. |
---|---|
value | The CharSequence array data value. |
Returns
- Returns the same Intent object, for chaining multiple calls into a single statement.
public Intent putExtras (Intent src)
Copy all extras in 'src' in to this intent.
Parameters
src | Contains the extras to copy. |
---|
See Also
public Intent putExtras (Bundle extras)
Add a set of extended data to the intent. The keys must include a package prefix, for example the app com.android.contacts would use names like "com.android.contacts.ShowAll".
Parameters
extras | The Bundle of extras to add to this intent. |
---|
public Intent putIntegerArrayListExtra (String name, ArrayList<Integer> value)
Add extended data to the intent. The name must include a package prefix, for example the app com.android.contacts would use names like "com.android.contacts.ShowAll".
Parameters
name | The name of the extra data, with package prefix. |
---|---|
value | The ArrayList data value. |
Returns
- Returns the same Intent object, for chaining multiple calls into a single statement.
public Intent putParcelableArrayListExtra (String name, ArrayList<? extends Parcelable> value)
Add extended data to the intent. The name must include a package prefix, for example the app com.android.contacts would use names like "com.android.contacts.ShowAll".
Parameters
name | The name of the extra data, with package prefix. |
---|---|
value | The ArrayList data value. |
Returns
- Returns the same Intent object, for chaining multiple calls into a single statement.
public Intent putStringArrayListExtra (String name, ArrayList<String> value)
Add extended data to the intent. The name must include a package prefix, for example the app com.android.contacts would use names like "com.android.contacts.ShowAll".
Parameters
name | The name of the extra data, with package prefix. |
---|---|
value | The ArrayList data value. |
Returns
- Returns the same Intent object, for chaining multiple calls into a single statement.
public void removeCategory (String category)
Remove a category from an intent.
Parameters
category | The category to remove. |
---|
See Also
public void removeExtra (String name)
Remove extended data from the intent.
See Also
public Intent replaceExtras (Bundle extras)
Completely replace the extras in the Intent with the given Bundle of extras.
Parameters
extras | The new set of extras in the Intent, or null to erase all extras. |
---|
public Intent replaceExtras (Intent src)
Completely replace the extras in the Intent with the extras in the given Intent.
Parameters
src | The exact extras contained in this Intent are copied into the target intent, replacing any that were previously there. |
---|
public ComponentName resolveActivity (PackageManager pm)
Return the Activity component that should be used to handle this intent. The appropriate component is determined based on the information in the intent, evaluated as follows:
If getComponent()
returns an explicit class, that is returned without any further consideration.
The activity must handle the CATEGORY_DEFAULT
Intent category to be considered.
If getAction()
is non-NULL, the activity must handle this action.
If resolveType(ContentResolver)
returns non-NULL, the activity must handle this type.
If addCategory(String)
has added any categories, the activity must handle ALL of the categories specified.
If getPackage()
is non-NULL, only activity components in that application package will be considered.
If there are no activities that satisfy all of these conditions, a null string is returned.
If multiple activities are found to satisfy the intent, the one with the highest priority will be used. If there are multiple activities with the same priority, the system will either pick the best activity based on user preference, or resolve to a system class that will allow the user to pick an activity and forward from there.
This method is implemented simply by calling resolveActivity(Intent, int)
with the "defaultOnly" parameter true.
This API is called for you as part of starting an activity from an intent. You do not normally need to call it yourself.
Parameters
pm | The package manager with which to resolve the Intent. |
---|
Returns
- Name of the component implementing an activity that can display the intent.
public ActivityInfo resolveActivityInfo (PackageManager pm, int flags)
Resolve the Intent into an ActivityInfo
describing the activity that should execute the intent. Resolution follows the same rules as described for resolveActivity(PackageManager)
, but you get back the completely information about the resolved activity instead of just its class name.
Parameters
pm | The package manager with which to resolve the Intent. |
---|---|
flags | Addition information to retrieve as per PackageManager.getActivityInfo() . |
Returns
- PackageManager.ActivityInfo
See Also
public String resolveType (ContentResolver resolver)
Return the MIME data type of this intent. If the type field is explicitly set, that is simply returned. Otherwise, if the data is set, the type of that data is returned. If neither fields are set, a null is returned.
Parameters
resolver | A ContentResolver that can be used to determine the MIME type of the intent's data. |
---|
Returns
- The MIME type of this intent.
See Also
public String resolveType (Context context)
Return the MIME data type of this intent. If the type field is explicitly set, that is simply returned. Otherwise, if the data is set, the type of that data is returned. If neither fields are set, a null is returned.
Returns
- The MIME type of this intent.
public Intent setAction (String action)
Set the general action to be performed.
Parameters
action | An action name, such as ACTION_VIEW. Application-specific actions should be prefixed with the vendor's package name. |
---|
Returns
- Returns the same Intent object, for chaining multiple calls into a single statement.
See Also
public Intent setClass (Context packageContext, Class<?> cls)
Convenience for calling setComponent(ComponentName)
with the name returned by a Class
object.
Parameters
packageContext | A Context of the application package implementing this class. |
---|---|
cls | The class name to set, equivalent to setClassName(context, cls.getName()) . |
Returns
- Returns the same Intent object, for chaining multiple calls into a single statement.
See Also
public Intent setClassName (Context packageContext, String className)
Convenience for calling setComponent(ComponentName)
with an explicit class name.
Parameters
packageContext | A Context of the application package implementing this class. |
---|---|
className | The name of a class inside of the application package that will be used as the component for this Intent. |
Returns
- Returns the same Intent object, for chaining multiple calls into a single statement.
public Intent setClassName (String packageName, String className)
Convenience for calling setComponent(ComponentName)
with an explicit application package name and class name.
Parameters
packageName | The name of the package implementing the desired component. |
---|---|
className | The name of a class inside of the application package that will be used as the component for this Intent. |
Returns
- Returns the same Intent object, for chaining multiple calls into a single statement.
public void setClipData (ClipData clip)
Set a ClipData
associated with this Intent. This replaces any previously set ClipData.
The ClipData in an intent is not used for Intent matching or other such operations. Semantically it is like extras, used to transmit additional data with the Intent. The main feature of using this over the extras for data is that FLAG_GRANT_READ_URI_PERMISSION
and FLAG_GRANT_WRITE_URI_PERMISSION
will operate on any URI items included in the clip data. This is useful, in particular, if you want to transmit an Intent containing multiple content:
URIs for which the recipient may not have global permission to access the content provider.
If the ClipData contains items that are themselves Intents, any grant flags in those Intents will be ignored. Only the top-level flags of the main Intent are respected, and will be applied to all Uri or Intent items in the clip (or sub-items of the clip).
The MIME type, label, and icon in the ClipData object are not directly used by Intent. Applications should generally rely on the MIME type of the Intent itself, not what it may find in the ClipData. A common practice is to construct a ClipData for use with an Intent with a MIME type of "*\/*".
Parameters
clip | The new clip to set. May be null to clear the current clip. |
---|
public Intent setComponent (ComponentName component)
(Usually optional) Explicitly set the component to handle the intent. If left with the default value of null, the system will determine the appropriate class to use based on the other fields (action, data, type, categories) in the Intent. If this class is defined, the specified class will always be used regardless of the other fields. You should only set this value when you know you absolutely want a specific class to be used; otherwise it is better to let the system find the appropriate class so that you will respect the installed applications and user preferences.
Parameters
component | The name of the application component to handle the intent, or null to let the system find one for you. |
---|
Returns
- Returns the same Intent object, for chaining multiple calls into a single statement.
public Intent setData (Uri data)
Set the data this intent is operating on. This method automatically clears any type that was previously set by setType(String)
or setTypeAndNormalize(String)
.
Note: scheme matching in the Android framework is case-sensitive, unlike the formal RFC. As a result, you should always write your Uri with a lower case scheme, or use normalizeScheme()
or setDataAndNormalize(Uri)
to ensure that the scheme is converted to lower case.
Parameters
data | The Uri of the data this intent is now targeting. |
---|
Returns
- Returns the same Intent object, for chaining multiple calls into a single statement.
public Intent setDataAndType (Uri data, String type)
(Usually optional) Set the data for the intent along with an explicit MIME data type. This method should very rarely be used -- it allows you to override the MIME type that would ordinarily be inferred from the data with your own type given here.
Note: MIME type and Uri scheme matching in the Android framework is case-sensitive, unlike the formal RFC definitions. As a result, you should always write these elements with lower case letters, or use normalizeMimeType(String)
or normalizeScheme()
or setDataAndTypeAndNormalize(Uri, String)
to ensure that they are converted to lower case.
Parameters
data | The Uri of the data this intent is now targeting. |
---|---|
type | The MIME type of the data being handled by this intent. |
Returns
- Returns the same Intent object, for chaining multiple calls into a single statement.