惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Google Online Security Blog
Google Online Security Blog
S
Security @ Cisco Blogs
Recent Commits to openclaw:main
Recent Commits to openclaw:main
人人都是产品经理
人人都是产品经理
The Hacker News
The Hacker News
W
WeLiveSecurity
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
The Cloudflare Blog
博客园 - 司徒正美
雷峰网
雷峰网
L
LINUX DO - 最新话题
博客园 - 叶小钗
云风的 BLOG
云风的 BLOG
The Last Watchdog
The Last Watchdog
V2EX - 技术
V2EX - 技术
S
Security Affairs
有赞技术团队
有赞技术团队
月光博客
月光博客
T
Threatpost
T
Tor Project blog
O
OpenAI News
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
V
V2EX
Know Your Adversary
Know Your Adversary
Project Zero
Project Zero
博客园 - 三生石上(FineUI控件)
D
Docker
AWS News Blog
AWS News Blog
AI
AI
P
Proofpoint News Feed
K
Kaspersky official blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
D
Darknet – Hacking Tools, Hacker News & Cyber Security
www.infosecurity-magazine.com
www.infosecurity-magazine.com
S
Securelist
F
Fortinet All Blogs
F
Full Disclosure
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
量子位
Hacker News - Newest:
Hacker News - Newest: "LLM"
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
P
Palo Alto Networks Blog
Cyberwarzone
Cyberwarzone
Cisco Talos Blog
Cisco Talos Blog
美团技术团队
N
News | PayPal Newsroom
T
The Blog of Author Tim Ferriss
MyScale Blog
MyScale Blog

博客园 - verygis

C++/CLI 本地字符串和托管字符串之间的转换 DWF Toolkit on Microsoft Windows Visual studio 2017 c++ wcout 无法输出中文 Javascript 技巧集(1) win10 下 gulp-sass 无法使用的解决 VS2010 下 将 EntityFramework 的版本从 4.0 升级到 5.0 [原]CentOS 6.5 上安装 MySQL 5.6 Filezilla 适用于 Win2003 和 WinXP 的版本 Bower 自定义组件文件夹名称 [原]JQuery mobile CSS 文件组织 [转]Django与遗留系统和数据库集成 [转]mysql在windows下支持表名大小写,lower_case_table_names [转]Installing python 2.7 on centos 6.3. Follow this sequence exactly for centos machine only [转]如何判断某版本的.NET Framework是否安装 [转]Convert Windows TCHAR argv list to classical char * argv Google V8 源码下载及构建环境 关于网络字节序(network byte order)和主机字节序(host byte order) 宏 UNUSED_PARAM 的作用 [转]在C#中使用IDL文件,IDL是个接口定义文件
[转]理解android.intent.category.LAUNCHER 具体作用
verygis · 2013-12-15 · via 博客园 - verygis

转自:http://blog.csdn.net/jackrex/article/details/9189657

android.intent.category.LAUNCHER 具体有什么作用?我做一个小例子希望帮助大家理解

<activity android:name="APAct">      <intent-filter>           <action android:name="android.intent.action.MAIN" />         <category android:name="android.intent.category.LAUNCHER" />     </intent-filter> </activity> <activity android:name="URLAct">          <intent-filter>                <category android:name="android.intent.category.LAUNCHER" />          </intent-filter> </activity>

 一个应用程序可以有多个Activity,每个Activity是同级别的,那么在启动程序时,最先启动哪个Activity呢?有些程序可能需要显示在程序列表里,有些不需要。怎么定义呢?android.intent.action.MAIN决定应用程序最先启动的Activity android.intent.category.LAUNCHER决定应用程序是否显示在程序列表里

因为你的程序可能有很多个activity 只要xml配置文件中有这么一个intent-filter,而且里面有这个launcher,那么这个activity就是点击程序时最先运行的那个activity。
<activity android:name="APAct">
     <intent-filter>
          <action android:name="android.intent.action.MAIN" />
       
    </intent-filter>
</activity>
<activity android:name="URLAct">
         <intent-filter>
               <category android:name="android.intent.category.LAUNCHER" />
         </intent-filter>
</activity>
如果代码是这个样子的,那么还是会不会在显示出到列表中的, 也就是说main 和 launcher是配合使用的

<activity android:name="APAct">
     <intent-filter>
          <action android:name="android.intent.action.MAIN" />
          <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>
<activity android:name="URLAct">
         <intent-filter>
            <action android:name="android.intent.action.MAIN" />
          <category android:name="android.intent.category.LAUNCHER" />

         </intent-filter>
</activity>
如果是这样的话,就会出现两个图标在列表里。

用于模拟器启动时设置为默认打开为的activity

 还有 为什么加入android.intent.category.DEFAULT

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

从上面的论述还可以获得以下信息: 1、一个 Intent 可以有多个 category,但至少会有一个,也是默认的一个 category。 2、只有 Intent 的所有 category 都匹配上,Activity 才会接收这个 Intent。