intent组件间的桥梁

intent:翻译为意图,是android组件间或者应用间跳转传递数据的一种方式。分为显式启动,隐式启动两种方式。 


intent的六种属性:

component name 组件名  指定启动组件的名字,一般用于一个应用内部的显示启动 

category 种类   没有指定则为默认default

action 动作  指定将要启动的应用将要做什么 例如打电话 一般用于进程间通讯,隐式启动

data 数据   指定数据包括type和uri(唯一资源定位符) 两部分

extras 额外的数据 一个键值对

flag 启动模式


intent filter的匹配:

intent和intent filter配套使用,通过intent filter来匹配发送的intent。

intent filter写在manifest里面例如:

<activity android:name=".MainActivity">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>
每个组件可以有若干个intent filter,影响匹配的只有category,action,data不包括extras,flag。
其中data比较复杂:
mime type:
类型/子类型
application/javascript
application/zip
audio/mp3
audio/quicktime
video/mp4
text/html
text/XML
text/plain
image/jpeg
image/png
image/*
 
uri:
scheme://host:port/path
http表示网络协议
content表示本地content provider提供的数据
file表示文件
例如:content://com.google.provider.notepad/notes



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值