<动作>
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
- 语法:
<action android:name="string" />
- 包含于:
<intent-filter>
- 说明:
- 向 Intent 过滤器添加操作。
<intent-filter>
元素必须包含一个或多个 <action>
元素。如果 Intent 过滤器中没有 <action>
元素,则过滤器不接受任何 Intent
对象。
如需详细了解 intent 过滤器以及操作规范在过滤器中的作用,请参阅 intent 和 intent 过滤器。
- 属性:
android:name
- 操作的名称。某些标准操作在
Intent
类中定义为 ACTION_string
常量。若要将其中一项操作分配给此属性,请在 ACTION_
之后的 string
前面加上 android.intent.action.
。
例如,对于 ACTION_MAIN
,请使用 android.intent.action.MAIN
;对于 ACTION_WEB_SEARCH
,请使用 android.intent.action.WEB_SEARCH
。
对于您定义的操作,最好将应用的软件包名称用作前缀,以帮助确保唯一性。例如,可按如下方式指定 TRANSMOGRIFY
操作:
<action android:name="com.example.project.TRANSMOGRIFY" />
- 引入于:
- API 级别 1
- 另请参阅:
<intent-filter>
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-27。
[null,null,["最后更新时间 (UTC):2025-07-27。"],[],[],null,["# <action\u003e\n\nsyntax:\n:\n\n ```xml\n \u003caction android:name=\"string\" /\u003e\n ```\n\ncontained in:\n: [\u003cintent-filter\u003e](/guide/topics/manifest/intent-filter-element)\n\ndescription:\n: Adds an action to an intent filter.\n An [\u003cintent-filter\u003e](/guide/topics/manifest/intent-filter-element)\n element must contain one or more `\u003caction\u003e` elements. If there\n are no `\u003caction\u003e` elements in an intent filter, the filter\n doesn't accept any [Intent](/reference/android/content/Intent) objects.\n For details about intent filters and the role of action\n specifications within a filter, see\n [Intents and\n Intent Filters](/guide/components/intents-filters).\n\nattributes:\n:\n\n `android:name`\n : The name of the action. Some standard actions are defined in the\n [Intent](/reference/android/content/Intent#ACTION_CHOOSER) class as\n `ACTION_`*string* constants. To assign one of these actions to\n this attribute, prepend `android.intent.action.` to the\n *string* that follows `ACTION_`.\n For example, for `ACTION_MAIN`, use `android.intent.action.MAIN`,\n and for `ACTION_WEB_SEARCH`, use `android.intent.action.WEB_SEARCH`.\n\n\n For actions you define, it's best to use your app's package name as a prefix to\n help ensure uniqueness. For example, a `TRANSMOGRIFY` action might be specified\n as follows:\n\n\n ```xml\n \u003caction android:name=\"com.example.project.TRANSMOGRIFY\" /\u003e\n ```\n\nintroduced in:\n: API Level 1\n\nsee also:\n: [\u003cintent-filter\u003e](/guide/topics/manifest/intent-filter-element)"]]