IntentFilter的使用

来源:互联网 发布:mac暗影格斗2修改 编辑:程序博客网 时间:2024/06/10 17:40

一、IntentFilter的分类

1、action IntentFilter必须包含一个Action
2、category IntentFilter若不包含其他Category则必须设置默认的”android.intent.category.DEFAULT”这个Category
3、data 若定义了data则必须匹配

二、data的组成

<data android:scheme=""android:host=""android:port=""android:path=""android:pathPattern=""android:pathPrefix=""android:mimeType=""/>

其中 pathPattern表示通配符部分。pathPrefix表示前缀信息
2、匹配方法
若指定了MimeType必须同时设置Data和Type 如:intent.setDataAndType(Uri.pare(“file://abc”),”image/png”);
若data未指定默认值为content和file

三、检测隐式调用的Intent是否成功

通过resolveActivity即可判断是否存在隐式的Activity

0 0
原创粉丝点击