- 语法:
<category android:name="string" />
- 包含于:
<intent-filter>
- 说明:
- 向 Intent 过滤器添加类别名称。如需详细了解 Intent 过滤器和类别规范在过滤器中的作用,请参阅 Intent 和 Intent 过滤器。
- 属性:
android:name
- 类别的名称。标准类别在
Intent
类中定义为CATEGORY_name
常量。此处分配的名称可以根据这些常量推导出来,方法是在CATEGORY_
后跟的name
前面加上“android.intent.category.
”作为前缀。例如,CATEGORY_LAUNCHER
的字符串值为“android.intent.category.LAUNCHER
”。注意:为了接收隐式 intent,您必须在 intent 过滤器中添加
CATEGORY_DEFAULT
类别。startActivity()
和startActivityForResult()
方法将所有 intent 当作声明了CATEGORY_DEFAULT
类别一样对待。如果您没有在 Intent 过滤器中声明该类别,则任何隐式 Intent 都不会解析为您的 Activity。自定义类别应将软件包名称用作前缀,以确保它们的唯一性。
- 引入于:
- API 级别 1
- 另请参阅:
<action>
<data>
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2022-03-01 UTC.
[]
[]