<動作>
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
- 語法:
<action android:name="string" />
- 包含於:
<intent-filter>
- 說明:
- 新增動作至意圖篩選器。
<intent-filter>
元素必須包含一或多個 <action>
元素。如果有
意圖篩選器中沒有任何 <action>
元素,篩選器
不接受任何 Intent
物件。
進一步瞭解意圖篩選器和動作角色
套用篩選器的規格,請參閱
意圖和
意圖篩選器。
- 屬性:
android:name
- 動作的名稱。部分標準動作在
Intent
類別中定義為 ACTION_string
常數。如何將其中一個動作指派給
請在此屬性的前面加上 android.intent.action.
ACTION_
後方的 string
。
例如,如果是 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 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-07-27 (世界標準時間)。
[null,null,["上次更新時間: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)"]]