我们需要什么时候加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. 20155321 2016-2017-2 《Java程序设计》第八周学习总结

    20155321 2016-2017-2 <Java程序设计>第八周学习总结 教材学习内容总结 创建Logger对象 static Logger getLogger(String name ...

  2. 20155215 2016-2017-2 《Java程序设计》第8周学习总结

    20155215 2016-2017-2 <Java程序设计>第7周学习总结 教材学习内容总结 第十四章 NIO使用频道(Channel)来衔接数据节点.在处理数据时,NIO可以让你设置缓 ...

  3. Java 学习札记(一)JDK安装配置

    Windows上配置JDK 1.下载windows版JDK 网址:http://www.oracle.com/technetwork/java/javase/archive-139210.html 2 ...

  4. (A - 整数划分 HYSBZ - 1263)(数组模拟大数乘法)

    题目链接:https://cn.vjudge.net/problem/HYSBZ-1263 题目大意:中文题目 具体思路:先进了能的拆成3,如果当前剩下的是4,就先不减去3,直接乘4,如果还剩2的话, ...

  5. Wordpress页脚

    <?php /** * The template for displaying the footer */ ?> <?php if ( apply_filters( 'show_fl ...

  6. redhat7配置本地yum源

    1.首先是要有一个iso文件,并将这个文件挂载到某个目录 挂载: 配置: 检验: yum list 现在你就可以在没有网的情况下,安装软件了~~~

  7. c# 获取百度最后的url

    using System;using System.Collections.Generic;using System.Linq;using System.Net.Http;using System.T ...

  8. 为你详细解读HTTP请求头的具体含意

    当我们打开一个网页时,浏览器要向网站服务器发送一个HTTP请求头,然后网站服务器根据HTTP请求头的内容生成当次请求的内容发送给浏览器.你明白HTTP请求头的具体含意吗?下面一条条的为你详细解读,先看 ...

  9. JVM(3)对象A和B循环引用,最后会不会不被GC回收?-------关于Java的GC机制

    ①首先说一下,GC里边在JVM其中是使用的ROOT算法,ROOT算法,什么称作为ROOT呢,就是说类的静态成员,静态成员就是static修饰的那种,是"根"的一个,根还包含方法中的 ...

  10. docker 构建带健康检查的redis镜像

    =============================================== 2018/11/5_第1次修改                       ccb_warlock == ...