- ไวยากรณ์:
<category android:name="string" />
- ที่อยู่ใน:
<intent-filter>
- description:
- เพิ่มชื่อหมวดหมู่ลงในตัวกรอง Intent โปรดดู ความตั้งใจและ ตัวกรอง Intent สำหรับรายละเอียดเกี่ยวกับตัวกรอง Intent และบทบาทของหมวดหมู่ ข้อกำหนดเฉพาะภายในตัวกรอง
- ดังนี้
android:name
- ชื่อหมวดหมู่ หมวดหมู่มาตรฐานจะกำหนดใน
Intent
ชั้นเรียนเป็นCATEGORY_name
ค่าคงที่นี้ ชื่อที่กำหนดไว้ที่นี่ได้มาจากค่าคงที่เหล่านั้น โดยใส่android.intent.category.
เป็นคำนำหน้าname
ที่ตามหลังCATEGORY_
ตัวอย่างเช่น ค่าสตริงสำหรับCATEGORY_LAUNCHER
คือandroid.intent.category.LAUNCHER
หมายเหตุ: หากต้องการรับ Intent แบบไม่เจาะจงปลายทาง คุณต้องใส่
CATEGORY_DEFAULT
ในตัวกรอง Intent วิธีการstartActivity()
และstartActivityForResult()
จะถือว่า Intent ทั้งหมด เหมือนกับว่าได้ประกาศหมวดหมู่CATEGORY_DEFAULT
ไว้ หากคุณไม่ได้ประกาศไว้ในตัวกรอง Intent จะแก้ไขปัญหา Intent แบบไม่เจาะจงปลายทางไม่ได้ กิจกรรมของคุณสำหรับหมวดหมู่ที่กำหนดเอง ให้ใช้ชื่อแพ็กเกจเป็นคำนำหน้าเพื่อ ว่าไม่ซ้ำกัน
- เปิดตัวใน
- API ระดับ 1
- ดูเพิ่มเติม
<action>
<data>
<category>
ตัวอย่างเนื้อหาและโค้ดในหน้าเว็บนี้ขึ้นอยู่กับใบอนุญาตที่อธิบายไว้ในใบอนุญาตการใช้เนื้อหา Java และ OpenJDK เป็นเครื่องหมายการค้าหรือเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-27 UTC
[[["เข้าใจง่าย","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 UTC"],[],[],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)"]]