使用步骤
Intent对象设置action方法The action in an Intent object is set by themethod and read by
setAction()
.
getAction()
Intent对象设置data和typeThemethod specifies data only as a URI,
setData()
specifies it only as a MIME type, and
setType()
specifies it as both a URI and a MIME type. The URI is read by
setDataAndType()
and the type by
getData()
.
getType()
Intent对象设置categoryThemethod places a category in an Intent object,
addCategory()
deletes a category previously added, and
removeCategory()
gets the set of all categories currently in the object.
getCategories()
Intent设置附加数据the extras can be installed and read as a Bundle using theand
putExtras()
methods.
getExtras()
sendStickyBroadcast()
- An Intent object that contains neither a URI nor a data type passes the test only if the filter likewise does not specify any URIs or data types.
-
An Intent object that contains a URI but no data type (and a type cannot be inferred from the URI) passes the test only if its URI matches a URI in the filter and the filter likewise does not specify a type. This will be the case only for URIs like
mailto:
andtel:
that do not refer to actual data. -
An Intent object that contains a data type but not a URI passes the test only if the filter lists the same data type and similarly does not specify a URI.
-
An Intent object that contains both a URI and a data type (or a data type can be inferred from the URI) passes the data type part of the test only if its type matches a type listed in the filter. It passes the URI part of the test either if its URI matches a URI in the filter or if it has a
content:
orfile:
URI and the filter does not specify a URI. In other words, a component is presumed to supportcontent:
andfile:
data if its filter lists only a data type.
<intent-filter> <action android:name="android.intent.action.VIEW" /> <action android:name="android.intent.action.EDIT" /> <action android:name="android.intent.action.PICK" /> <category android:name="android.intent.category.DEFAULT" /> <data android:mimeType="vnd.android.cursor.dir/vnd.google.note" /> </intent-filter>