Android API Guides 之 App Manifest(6) - <category>

本文深入探讨了Android应用中Intent Filters和Categories的概念,解释了如何通过配置Intent Filters来实现活动之间的交互,强调了包含Category Default的重要性,以及自定义Category的规范。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<category>

SYNTAX:
<category android:name="string" />
CONTAINED IN:
<intent-filter>
DESCRIPTION:
Adds a category name to an intent filter. See  Intents and Intent Filters for details on intent filters and the role of category specifications within a filter.
ATTRIBUTES:
android:name
The name of the category. Standard categories are defined in the  Intent class as  CATEGORY_nameconstants. The name assigned here can be derived from those constants by prefixing " android.intent.category." to the  name that follows  CATEGORY_. For example, the string value for CATEGORY_LAUNCHER is " android.intent.category.LAUNCHER".

Note: In order to receive implicit intents, you must include the CATEGORY_DEFAULT category in the intent filter. The methods startActivity() and startActivityForResult() treat all intents as if they declared the CATEGORY_DEFAULT category. If you do not declare it in your intent filter, no implicit intents will resolve to your activity.

Custom categories should use the package name as a prefix, to ensure that they are unique.

INTRODUCED IN:
API Level 1
SEE ALSO:
<action> 
<data>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值