summary
1.1 Intent is request for in (Context Class)
1.1.1 start activity
1.1.2 start service
1.1.3 deliver a broadcast
1.2 Intent filter is the capibility description of app components
1.2.3 Don’t use intent filter for serviceIntent
2.1 Intent 组成
2.1.1 optional component for explicit intent
2.1.2 Action , standard action defined in Intent class
2.1.3 Data ( URI and data mimi type)
2.1.4 Flags
2.1.5 Extra
2.2 Pending Intent : A intent will be delivered as myself and in future.
3.Intent filter
<activity android:name="MainActivity">
<!-- This activity is the main entry, should appear in app launcher -->
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="ShareActivity">
<!-- This activity handles "SEND" actions with text data -->
<intent-filter>
<action android:name="android.intent.action.SEND"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="text/plain"/>
</intent-filter>
<!-- This activity also handles "SEND" and "SEND_MULTIPLE" with media data -->
<intent-filter>
<action android:name="android.intent.action.SEND"/>
<action android:name="android.intent.action.SEND_MULTIPLE"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="application/vnd.google.panorama360+jpg"/>
<data android:mimeType="image/*"/>
<data android:mimeType="video/*"/>
</intent-filter>
</activity>
4.Intent and filter 匹配
4.1 Action 匹配
4.2 Category 匹配
4.3 data 匹配(必须匹配意味着NULL的字段必须参与,且只等于NULL的字段)
4.3.1 Mime type 可从uri推出,若原无,使用导出的
4.3.2 Mime type 必须匹配, intent‘s == filter’s
4.3.3 data 必须匹配 除了:如果data包含 content: 或 file: ,data可匹配 filter中的data==NULL
4.3.4 data 格式 <scheme>://<host>:<port>/<path>
If a scheme is not specified, the host is ignored.
If a host is not specified, the port is ignored.
If both the scheme and host are not specified, the path is ignored.
- 可使用PackageManager接口获得匹配的结果
- 可强制弹出目标选择对话框。 Intent.createChooser()
- Start activity by adb
adb shell am start -a <ACTION> -t <MIME_TYPE> -d <DATA> \
-e <EXTRA_NAME> <EXTRA_VALUE> -n <ACTIVITY>
Intent action defined in Intent class.
ACTION_MAIN
This is used for main start, no date given
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
系统提供了一些标准功能能通过intent访问
1。Phone/SMS/Email
2。Camera/Music
3。Alarm/Calendar
4。Search/WEb/map
5。File storage
6。Setting