intent ,intent filter comments

  1. 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 service

  2. Intent
    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.

  1. 可使用PackageManager接口获得匹配的结果
  2. 可强制弹出目标选择对话框。 Intent.createChooser()
  3. 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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值