- 語法:
<category android:name="string" />
- 包含於:
<intent-filter>
- 說明:
- 新增類別名稱至意圖篩選器。如需有關意圖篩選器和篩選器中類別規格角色的詳細資料,請參閱「意圖和意圖篩選器」。
- 屬性:
android:name
- 類別的名稱。標準類別在
Intent
類別中定義為CATEGORY_name
常數。這裡指派的名稱衍生自這些常數 方法是在網址前方加上android.intent.category.
CATEGORY_
後方的name
。例如:CATEGORY_LAUNCHER
的字串值是android.intent.category.LAUNCHER
。注意:如要接收隱含意圖,您必須在意圖篩選器中加入
CATEGORY_DEFAULT
類別。startActivity()
和startActivityForResult()
方法會將所有意圖視為宣告CATEGORY_DEFAULT
類別。如果您未在意圖篩選器中完成宣告,系統就不會將任何隱含意圖解析 您的活動。如果是自訂類別,請使用套件名稱做為前置字元 以及這些不重複的
- 導入版本:
- API 級別 1
- 另請參閱:
<action>
<data>
<類別>
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-07-27 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-07-27 (世界標準時間)。"],[],[],null,["# <category\u003e\n\nsyntax:\n:\n\n ```xml\n \u003ccategory android:name=\"string\" /\u003e\n ```\n\ncontained in:\n: [\u003cintent-filter\u003e](/guide/topics/manifest/intent-filter-element)\n\ndescription:\n: Adds a category name to an intent filter. See\n [Intents and\n Intent Filters](/guide/components/intents-filters) for details on intent filters and the role of category\n specifications within a filter.\n\nattributes:\n:\n\n `android:name`\n : The name of the category. Standard categories are defined in the\n [Intent](/reference/android/content/Intent) class as `CATEGORY_`*name*\n constants. The name assigned here is derived from those constants\n by prefixing `android.intent.category.` to the\n *name* that follows `CATEGORY_`. For example,\n the string value for `CATEGORY_LAUNCHER` is\n `android.intent.category.LAUNCHER`.\n\n **Note:** To receive implicit intents, you must include the\n [CATEGORY_DEFAULT](/reference/android/content/Intent#CATEGORY_DEFAULT) category in the intent filter. The methods\n [startActivity()](/reference/android/app/Activity#startActivity(android.content.Intent)) and\n [startActivityForResult()](/reference/android/app/Activity#startActivityForResult(android.content.Intent, int)) treat all intents\n as if they declared the [CATEGORY_DEFAULT](/reference/android/content/Intent#CATEGORY_DEFAULT) category.\n If you don't declare it in your intent filter, no implicit intents can resolve\n your activity.\n\n\n For custom categories, use the package name as a prefix so\n that they are unique.\n\nintroduced in:\n: API Level 1\n\nsee also:\n: [\u003caction\u003e](/guide/topics/manifest/action-element)\n\n [\u003cdata\u003e](/guide/topics/manifest/data-element)"]]