http://blog.csdn.net/cnnumen/article/details/8464786

IntentFilter就是用于描述intent的各种属性, 比如action, category等

一些属性设置的例子:

<action android:name="com.example.project.SHOW_CURRENT" />

<category android:name="android.intent.category.DEFAULT" />

<data android:mimeType="video/mpeg" android:scheme="http" . . . />

<data android:mimeType="image/*" />

<data android:scheme="http" android:type="video/*" />

关于IntentFilter的几点注意事项

(1).android.intent.action.MAIN 与 android.intent.category.LAUNCHER

android.intent.action.MAIN决定一个应用程序最先启动那个组件

android.intent.category.LAUNCHER决定应用程序是否显示在程序列表里(说白了就是是否在桌面上显示一个图标)

这两个属性组合情况:

第一种情况:有MAIN,无LAUNCHER,程序列表中无图标

原因:android.intent.category.LAUNCHER决定应用程序是否显示在程序列表里

第二种情况:无MAIN,有LAUNCHER,程序列表中无图标

原因:android.intent.action.MAIN决定应用程序最先启动的Activity,如果没有Main,则不知启动哪个Activity,故也不会有图标出现

所以这两个属性一般成对出现。

如果一个应用中有两个组件intent-filter都添加了android.intent.action.MAIN和

android.intent.category.LAUNCHER这两个属性, 则这个应用将会显示两个图标, 写在前面的组件先运行。

(2).关于隐式intent

每一个通过 startActivity() 方法发出的隐式 Intent 都至少有一个 category,就是 "android.intent.category.DEFAULT",所以只要是想接收一个隐式 Intent 的 Activity 都应该包括 "android.intent.category.DEFAULT" category,不然将导致 Intent 匹配失败.

比如说一个activity组件要想被其他组件通过隐式intent调用, 则其在manifest.xml中的声明如下:

<activity android:name="com.gesture.QGestureListActivity">

<intent-filter>

<action android:name="com.google.test" />

<category android:name="android.intent.category.DEFAULT" />

</intent-filter>

</activity>

(3).关于intent-filter匹配优先级

首先查看Intent的过滤器(intent-filter),按照以下优先关系查找:action->data->category

(4).android.intent.category.LAUNCHER与android.intent.category.HOME的区别

android.intent.category.LAUNCHER:android.intent.category.LAUNCHER决定应用程序是否显示在程序列表里,就是android开机后的主程序列表。

android.intent.category.HOME:按住“HOME”键,该程序显示在HOME列表里。

关于IntentFilter的几点注意事项:的更多相关文章

  1. [转]Intent和IntentFilter详解

        Intent   Android中提供了Intent机制来协助应用间的交互与通讯,Intent负责对应用中一次操作的动作.动作涉及数据.附加数据进行描述,Android则根据此Intent的描 ...

  2. Android Intent和IntentFilter详解与使用及实现系统“分享”接口

    Intent Android中提供了Intent机制来协助应用间的交互与通讯,Intent负责对应用中一次操作的动作.动作涉及数据.附加数据进行描述,Android则根据此Intent的描述,负责找到 ...

  3. (五)Unity插件生成

    1)新建空的AndroidStudio工程,但是新建过程时最小SDK版本要与unity一致,如下图所示,本次操作均为api16 2)创建Library,如下图所示,新建module,然后选择Andro ...

  4. Android两个注意事项.深入了解Intent和IntentFilter(两)

    深入理解Intent和IntentFiler(二) 转载请表明出处:http://blog.csdn.net/u012637501(嵌入式_小J的天空)     在上一篇文章中,我们比較具体学习了&q ...

  5. Broadcast Receiver注意事项

    静态登记 <receiver android:name=".MyReceiver" android:enabled="true"> <inte ...

  6. 最新百度地图支持Fragment(注意事项)(转)

    原文: 最新百度地图支持Fragment(注意事项)   开篇:老的百度地图通常都要继承MapActivity,这样不利于代码的可扩展性,再加上Fragment的流行,老的百度地图已经远远不能满足的大 ...

  7. Android实现微信分享及注意事项

    一.获取帮助文档并下载相关资料 首先打开微信开放平台:https://open.weixin.qq.com/ 如果没有注册,请先注册并上传开发者资料等待审核. 资源中心----移动应用开发----分享 ...

  8. Android TV开发中所有的遥控器按键监听及注意事项,新增home键监听

    原文:Android TV开发中所有的遥控器按键监听及注意事项,新增home键监听 简单记录下android 盒子开发遥控器的监听 ,希望能帮到新入门的朋友们 不多说,直接贴代码 public cla ...

  9. jQuery UI resizable使用注意事项、实时等比例拉伸及你不知道的技巧

    这篇文章总结的是我在使用resizable插件的过程中,遇到的问题及变通应用的奇思妙想. 一.resizable使用注意事项 以下是我在jsfiddle上写的测试demo:http://jsfiddl ...

随机推荐

  1. C#根据IP地址和子网掩码计算广播地址

    using System.Net; /// <summary> /// 获得广播地址 /// </summary> /// <param name="ipAdd ...

  2. PyQT制作视频播放器

    Python应用03 使用PyQT制作视频播放器   作者:Vamei 出处:http://www.cnblogs.com/vamei 严禁任何形式转载. 最近研究了Python的两个GUI包,Tki ...

  3. 北京联想招聘-java 云服务开发工程师 加入qq 群:220486180 或者直接在此 留言咨询

     Position Title: 云服务开发工程师 Experience Required:  3 - 5 Years 负责联想企业网盘服务端开发  Position Requirements  1. ...

  4. 执行mount命令时找不到介质或者mount:no medium found的解决办法

    使用vmware时,在虚拟机设置里,设置CD/DVD为系统镜像,挂载时,有时会有找不到介质或者no medium found之类的提示. 根本原因是iso镜像并没有加载到虚拟机系统内. 解决办法: 首 ...

  5. Gradle tip #2: understanding syntax

    In the Part 1 we talked about tasks and different stages of the build lifecycle. But after I publish ...

  6. [CareerCup] 8.10 Implement a Hash Table 实现一个哈希表

    8.10 Design and implement a hash table which uses chaining (linked lists) to handle collisions. 这道题让 ...

  7. [CareerCup] 14.6 CircularArray 环形数组

    14.6 Implement a CircularArray class that supports an array-like data structure which can be efficie ...

  8. LeetCode:Word Break(DP)

    题目地址:http://oj.leetcode.com/problems/word-break/ 简单的动态规划问题,采用自顶向下的备忘录方法,代码如下: class Solution { publi ...

  9. LeetCode:Path Sum I II

    LeetCode:Path Sum Given a binary tree and a sum, determine if the tree has a root-to-leaf path such ...

  10. Jquery操作select,radio,input,p之类

    select的操作 变化后触发操作 $("#txtaddprojecturl").change(function(){ $("#addprojectname") ...