Intent-filter的使用
2012-08-10 14:09
260 查看
如果一个 Intent 请求在一片数据上执行一个动作, Android 如何知道哪个应用程序(和组件)能用来响应这个请求呢? Intent Filter就是 用来注册 Activity 、 Service 和 Broadcast Receiver 具有能在某种数据上执行一个动作的能力。
使用 Intent Filter ,应用程序组件告诉 Android ,它们能为其它程序的组件的动作请求提供服务,包括同一个程序的组件、本地的或第三方的应用程序。
为了注册一个应用程序组件为 Intent 处理者,在组件的 manifest 节点添加一个 intent-filter 标签。
在 Intent Filter 节点里使用下面的标签(关联属性),你能指定组件支持的动作、种类和数据:
1.动作测试
(1) 如果<intent-filter>中没有包含任何Action类型,那么无论什么Intent请求都无法和这条<intent-filter>匹配;
(2) 反之,如果Intent请求中没有设定Action类型,那么只要<intent-filter>中包含有Action类型,这个Intent请求就将顺利地通过<intent-filter>的行为测试。
2.类别测试
<intent-filter>元素可以包含<category>子元素,比如:
更多参考:http://www.vogella.com/articles/AndroidIntent/article.html
使用 Intent Filter ,应用程序组件告诉 Android ,它们能为其它程序的组件的动作请求提供服务,包括同一个程序的组件、本地的或第三方的应用程序。
为了注册一个应用程序组件为 Intent 处理者,在组件的 manifest 节点添加一个 intent-filter 标签。
在 Intent Filter 节点里使用下面的标签(关联属性),你能指定组件支持的动作、种类和数据:
1.动作测试
< intent-filter > < action android:name="com.example.project.SHOW_CURRENT" /> < action android:name="com.example.project.SHOW_RECENT" /> < action android:name="com.example.project.SHOW_PENDING" /> </ intent-filter >一条<intent-filter>元素至少应该包含一个<action>,否则任何Intent请求都不能和该<intent-filter>匹配。如果Intent请求的Action和<intent-filter>中个某一条<action>匹配,那么该Intent就通过了这条<intent-filter>的动作测试。如果Intent请求或<intent-filter>中没有说明具体的Action类型,那么会出现下面两种情况。
(1) 如果<intent-filter>中没有包含任何Action类型,那么无论什么Intent请求都无法和这条<intent-filter>匹配;
(2) 反之,如果Intent请求中没有设定Action类型,那么只要<intent-filter>中包含有Action类型,这个Intent请求就将顺利地通过<intent-filter>的行为测试。
2.类别测试
<intent-filter>元素可以包含<category>子元素,比如:
< intent-filter . . . > < category android:name="android.Intent.Category.DEFAULT" /> < category android:name="android.Intent.Category.BROWSABLE" /> </ intent-filter >
更多参考:http://www.vogella.com/articles/AndroidIntent/article.html
相关文章推荐
- 使用Intent-Filter来决定打开方式
- 安卓使用隐式Intent(intent-filter)从其他Activity返回MainActivity时,App停止运行,及使用intent步骤简介
- Android Intent Filter简单使用
- Android中Intent和Intent Filter 原理与使用详解
- android中intent-filter的分析和具体使用用例
- 使用Intent和IntentFilter进行通信
- Android Intent Filter简单使用
- android IntentFilter 使用之 data过滤
- Intent及intent-filter总结与使用
- android IntentFilter 使用之 data过滤
- 使用Intent filter 匹配相应的Activity or services
- 【Android 开发教程】使用Intent-Filter
- 【android_温故知新】使用 Intent 和 IntentFilter 进行通信
- 使用Intent和IntentFilter进行通信
- 使用Intent和IntentFilter通信
- 使用Intent和IntentFilter进行通信
- tag, dialog,popupwindow intent-filter的使用
- intent-filter中的三个子选项的使用 action----intent-filter-------------data的说明
- 使用极光推送时报错[AndroidUtil] AndroidManifest.xml missing intent filter for DaemonService
- Android Intent Filter简单使用