Intent的属性
来源:互联网 发布:pkpm加密狗 淘宝 编辑:程序博客网 时间:2024/05/17 22:30
1、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> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter>
的Activity,则Launcher会出现多个图标,点击不同的图标会进入不同的入口,启动不同的类。
2、对android.intent.category.DEFAULT的理解
1、intent分为隐式的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.LAUNCHER的filter中没有必要加入android.intent.category.DEFAULT,加入也没有问题。
我们定义的activity如果接受implicit intent的话,intent filer就一定要加上android.intent.category.DEFAULT这个category。
- Intent的属性-Component属性
- Intent属性的设置
- Intent属性的设置
- Intent的属性
- Intent的Flag属性
- Intent 的四大属性
- Intent 属性的作用
- Intent的属性
- Intent的属性
- Intent的七大属性
- Intent的七大属性
- Intent的七大属性
- Intent的七大属性:
- Intent的七大属性
- Intent属性的设置
- Intent的七大属性
- Android的Intent&IntentFilter Intent属性及Intent-filter配置
- Intent一堆属性的意义
- MySQL笔记
- 算法(二)字符串转化为整数
- performance tuning case: array search & date order by , data updated daily (use cursor solve it)
- 初始化和清理
- 数据结构基础5_顺序栈的实现
- Intent的属性
- 01背包 hihocoder第六周
- 黑马程序员一一Java基础语法(三)
- neo4j安装与示例
- Lock与synchronized 的区别
- Windows服务编写原理及探讨【2】
- 指定的 DSN 中,驱动程序和应用程序之间的体系结构不匹配
- Oracle index by table(Associative array) used in PostgreSQL
- 【Python】Learn Python the hard way, ex38 列表操作