我们需要什么时候加android.intent.category.DEFAULT呢?

1、要弄清楚这个问题,首先需要弄明白什么是implicit(隐式) intent什么是explicit(显示) intent。

Explicit Intent明确的指定了要启动的Acitivity ,比如以下Java代码: 
             Intent intent= new Intent(this, B.class)

Implicit Intent没有明确的指定要启动哪个Activity ,而是通过设置一些Intent Filter来让系统去筛选合适的Acitivity去启动。

2、intent到底发给哪个activity,需要进行三个匹配,一个是action,一个是category,一个是data。

理论上来说,如果intent不指定category,那么无论intent filter的内容是什么都应该是匹配的。但是,如果是implicit intent,android默认给加上一个CATEGORY_DEFAULT,这样的话如果intent filter中没有android.intent.category.DEFAULT这个category的话,匹配测试就会失败。所以,如果你的 activity支持接收implicit intent的话就一定要在intent filter中加入android.intent.category.DEFAULT。

例外情况是:android.intent.category.MAIN和android.intent.category.LAUNCHER的filter中没有必要加入android.intent.category.DEFAULT,当然加入也没有问题。

我们定义的activity如果接受implicit intent的话,intent filer就一定要加上android.intent.category.DEFAULT这个category。

我的问题就是出现在这里。忘记在intent-filter中加上了<category android:name="android.intent.category.DEFAULT" />了这个。

转自:http://www.cnblogs.com/roemin/archive/2011/08/11/2134442.html

android.intent.category.DEFAULT的更多相关文章

  1. 什么时候加上android.intent.category.DEFAULT

    什么时候加上android.intent.category.DEFAULT 1.要弄清楚这个问题,首先需要弄明白什么是implicit(隐藏) intent什么是explicit(明确) intent ...

  2. android之android.intent.category.DEFAULT的用途和使用

    1.要弄清楚这个问题,首先需要弄明白什么是implicit(隐藏) intent什么是explicit(明确) intent. Explicit Intent明确的指定了要启动的Acitivity , ...

  3. android细节之android.intent.category.DEFAULT的使用

    我们知道,实现android的Activity之间相互跳转需要用到Intent, Intent又分为显式Intent和隐式Intent, 显式Intent很简单,比如我在FirstActivity中想 ...

  4. [转]理解android.intent.category.LAUNCHER 具体作用

    转自:http://blog.csdn.net/jackrex/article/details/9189657 android.intent.category.LAUNCHER 具体有什么作用?我做一 ...

  5. android.intent.category.BROWSABLE

    参考: http://blog.csdn.net/annkie/article/details/8349626 http://xiechengfa.iteye.com/blog/1004991 BRO ...

  6. (转)android.intent.action.MAIN与android.intent.category.LAUNCHER

    android.intent.action.MAIN决定应用程序最先启动的Activity android.intent.category.LAUNCHER决定应用程序是否显示在程序列表里 在网上看到 ...

  7. 理解android.intent.action.MAIN 与 android.intent.category.LAUNCHER

    刚才看了一下sundy的视频<LLY110426_Android应用程序启动>,里面讲到luncher这个activity通过获取应用程序信息来加载应用程序,显示给用户,其中就是通过一个应 ...

  8. android.intent.action.MAIN 与 android.intent.category.LAUNCHER 的验证理解 (转)

    原文地址:android.intent.action.MAIN 与 android.intent.category.LAUNCHER 的验证理解 作者: 第一种情况:有MAIN,无LAUNCHER,程 ...

  9. android.intent.action.MAIN 与 android.intent.category.LAUNCHER 的验证理解

    第一种情况:有MAIN,无LAUNCHER,程序列表中无图标 原因:android.intent.category.LAUNCHER决定应用程序是否显示在程序列表里  第二种情况:无MAIN,有LAU ...

随机推荐

  1. 比特币全节点(bitcoind) eth 全节点

    运行全节点的用途:  1.挖矿  2.钱包   运行全节点,可以做关于btc的任何事情,例如创建钱包地址.管理钱包地址.发送交易.查询全网的交易信息等等 选个节点钱包:bitcoind 1.配置文件: ...

  2. vue控制台报错

    1. TypeError: Cannot read property '_withTask' of undefined 这是因为引用找不到导致的,比如: <button @click='aaa' ...

  3. Linux下sh文件运行及桌面环境双击运行sh文件

    sh文件运行: 1.修改为可执行权限: chmod u+x hello.sh 2.运行 ./hello.sh 3.不使用可执行权限修改,用sh直接运行 sh ./hello.sh 桌面环境双击运行sh ...

  4. js和jquery使按钮失效为不可用状态的方法

    设置disabled属性为true即为不可用状态. html代码: <input type="button" value="提交" id="bt ...

  5. linux下热插拔事件的产生是怎样通知到用户空间,kobject_uevent_env之uevent【转】

    转自:http://blog.csdn.net/myarrow/article/details/8259888 1.kobject, ktype, kset 1) kobject: 代表sysfs中的 ...

  6. C# 压缩文件 的创建

    using System;using System.IO.Compression; using System.Collections.Generic;using System.Linq;using S ...

  7. javascript 模拟按键点击提交

    上代码 <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> & ...

  8. sphinx 同时使用多个索引进行检索探究

    2014年2月15日 11:24:34 结论: 1.一次性使用多个索引进行查询的时候,返回的结果集中的fields字段没有什么清楚的意义(也没有找到文档对它的说明) 2.如果程序中一次搜索使用了多个索 ...

  9. 不借助autolt实现下载文件到指定目录

    今天尝试了下不用借助autolt完成下载文件到指定目录, 好处:在于集成回归,远程机可以绕过执行autolt程序权限问题,导致autolt程序无法调用,不能完成脚本的回归 Firefox浏览器已经成功 ...

  10. ecplise里的run as里只有run configurations是怎么回事?

    一.没有main方法 二.main方法所在的类不是在与文件名同名的类中