- ไวยากรณ์:
<intent-filter android:icon="drawable resource" android:label="string resource" android:priority="integer" > ... </intent-filter>
- อยู่ใน
<activity>
<activity-alias>
<service>
<receiver>
<provider>
- ต้องประกอบด้วยข้อมูลต่อไปนี้
<action>
- อาจมีข้อมูลต่อไปนี้
<category>
<data>
<uri-relative-filter-group>
- description:
- ระบุประเภทของ Intent ที่ตัวรับกิจกรรม บริการ หรือการออกอากาศจะตอบสนองได้ ตัวกรอง Intent จะประกาศความสามารถของคอมโพเนนต์หลัก ซึ่งได้แก่ สิ่งที่กิจกรรมหรือบริการทําได้ และประเภทของการส่งสัญญาณที่ตัวรับจัดการได้
ซึ่งจะเปิดคอมโพเนนต์ให้รับ Intent ประเภทที่โฆษณาไปพร้อมกับกรอง Intent ที่ไม่มีความหมายสําหรับคอมโพเนนต์ออก เนื้อหาส่วนใหญ่ของตัวกรองจะอธิบายโดยองค์ประกอบย่อย ดังนี้
ดูการพูดคุยเรื่องตัวกรองโดยละเอียดได้ที่หัวข้อIntent และตัวกรอง Intent และส่วนตัวกรอง Intent ในภาพรวมไฟล์ Manifest ของแอป
- แอตทริบิวต์
android:icon
- ไอคอนที่แสดงถึงกิจกรรม บริการ หรือตัวรับสัญญาณหลักเมื่อคอมโพเนนต์นั้นแสดงต่อผู้ใช้ว่ามีความสามารถตามที่ตัวกรองอธิบายไว้
แอตทริบิวต์นี้ตั้งค่าเป็นการอ้างอิงไปยังทรัพยากรที่วาดได้ซึ่งมีคำจำกัดความของรูปภาพ ค่าเริ่มต้นคือไอคอนที่ตั้งค่าโดยแอตทริบิวต์
icon
ของคอมโพเนนต์หลัก หากรายการหลักไม่ได้ระบุไอคอน ค่าเริ่มต้นจะเป็นไอคอนที่องค์ประกอบ<application>
กำหนดดูข้อมูลเพิ่มเติมเกี่ยวกับไอคอนตัวกรอง Intent ได้ที่ส่วนไอคอนและป้ายกำกับในภาพรวมของไฟล์ Manifest ของแอป
android:label
- ป้ายกำกับที่ผู้ใช้อ่านได้สำหรับคอมโพเนนต์หลัก ระบบจะใช้ป้ายกำกับนี้แทนป้ายกำกับที่ตั้งค่าโดยคอมโพเนนต์หลักเมื่อแสดงคอมโพเนนต์ต่อผู้ใช้ว่ามีความสามารถตามที่ตัวกรองอธิบาย
ระบบจะตั้งค่าป้ายกำกับเป็นข้อมูลอ้างอิงสำหรับทรัพยากรสตริงเพื่อให้แปลได้เช่นเดียวกับสตริงอื่นๆ ในอินเทอร์เฟซผู้ใช้ อย่างไรก็ตาม คุณสามารถตั้งค่าเป็นสตริงดิบได้เพื่อความสะดวกขณะพัฒนาแอปพลิเคชัน
ค่าเริ่มต้นคือป้ายกำกับที่กำหนดโดยคอมโพเนนต์หลัก หากรายการหลักไม่ได้ระบุป้ายกํากับ ค่าเริ่มต้นจะเป็นป้ายกํากับที่ตั้งค่าโดยแอตทริบิวต์
label
ขององค์ประกอบ<application>
ดูข้อมูลเพิ่มเติมเกี่ยวกับป้ายกำกับตัวกรอง Intent ได้ที่ส่วนไอคอนและป้ายกำกับในภาพรวมของไฟล์ Manifest ของแอป
android:priority
- ลําดับความสําคัญที่กําหนดให้กับคอมโพเนนต์หลักเพื่อจัดการ Intent ของประเภทที่ตัวกรองระบุ แอตทริบิวต์นี้มีความหมายสําหรับทั้งกิจกรรมและตัวรับการออกอากาศ
- ซึ่งจะให้ข้อมูลเกี่ยวกับความสามารถของกิจกรรมในการตอบสนองต่อความตั้งใจที่ตรงกับตัวกรอง เมื่อเทียบกับกิจกรรมอื่นๆ ที่ตอบสนองต่อความตั้งใจนั้นได้เช่นกัน เมื่อ Intent จัดการได้หลายกิจกรรมที่มีลําดับความสําคัญต่างกัน Android จะพิจารณาเฉพาะกิจกรรมที่มีค่าลําดับความสําคัญสูงกว่าเป็นเป้าหมายที่เป็นไปได้สําหรับ Intent
ซึ่งจะควบคุมลําดับที่ตัวรับการออกอากาศจะทํางานเพื่อรับข้อความการออกอากาศ โดยระบบจะเรียกใช้ตัวรับที่มีค่าลําดับความสําคัญสูงกว่าก่อนตัวที่มีค่าต่ำกว่า ลําดับมีผลกับข้อความแบบซิงค์เท่านั้น ระบบจะไม่สนใจสำหรับข้อความแบบไม่พร้อมกัน
ใช้แอตทริบิวต์นี้เฉพาะในกรณีที่คุณต้องกำหนดลำดับที่เฉพาะเจาะจงในการรับการออกอากาศ หรือต้องการบังคับให้ Android ให้ความสำคัญกับกิจกรรมหนึ่งมากกว่ากิจกรรมอื่นๆ
ค่าต้องเป็นจํานวนเต็ม เช่น
100
ตัวเลขที่สูงกว่าจะมีลำดับความสำคัญสูงกว่า ค่าเริ่มต้นคือ0
ในบางกรณี ระบบจะไม่สนใจลําดับความสําคัญที่ขอและจำกัดค่าไว้ที่
0
ซึ่งกรณีนี้จะเกิดขึ้นเมื่อ- แอปพลิเคชันที่ไม่มีสิทธิ์จะขอลำดับความสำคัญใดก็ได้ที่มากกว่า 0
- แอปพลิเคชันที่มีสิทธิ์จะขอลําดับความสําคัญ >0 สําหรับ
ACTION_VIEW
,ACTION_SEND
,ACTION_SENDTO
หรือACTION_SEND_MULTIPLE
ดูข้อมูลเพิ่มเติมได้ที่
setPriority()
android:order
ลําดับที่ระบบประมวลผลตัวกรองเมื่อมีตัวกรองหลายรายการตรงกัน
order
แตกต่างจากpriority
ตรงที่priority
มีผลกับแอปต่างๆ ขณะที่order
ช่วยขจัดความกำกวมของตัวกรองที่ตรงกันหลายรายการในแอปเดียวเมื่อตัวกรองหลายรายการจับคู่กันได้ ให้ใช้ Intent แบบมีทิศทางแทน
ค่าต้องเป็นจํานวนเต็ม เช่น
100
ระบบจะจับคู่ตัวเลขที่สูงกว่าก่อน ค่าเริ่มต้นคือ0
แอตทริบิวต์นี้เปิดตัวใน API ระดับ 28
android:autoVerify
- Android จำเป็นต้องยืนยันว่าไฟล์ JSON ของลิงก์เนื้อหาดิจิทัล (Digital Asset Links) จากโฮสต์ที่ระบุตรงกับแอปพลิเคชันนี้หรือไม่
โปรดดูข้อมูลเพิ่มเติมที่หัวข้อยืนยัน Android App Link
ค่าเริ่มต้นคือ
false
แอตทริบิวต์นี้เปิดตัวใน API ระดับ 23
- เปิดตัวใน
- API ระดับ 1
- ดูข้อมูลเพิ่มเติมได้ที่
<action>
<category>
<data>
<uri-relative-filter-group>
<ตัวกรองความตั้งใจ>
ตัวอย่างเนื้อหาและโค้ดในหน้าเว็บนี้ขึ้นอยู่กับใบอนุญาตที่อธิบายไว้ในใบอนุญาตการใช้เนื้อหา Java และ OpenJDK เป็นเครื่องหมายการค้าหรือเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-27 UTC
[null,null,["อัปเดตล่าสุด 2025-07-27 UTC"],[],[],null,["# <intent-filter\u003e\n\nsyntax:\n:\n\n ```xml\n \u003cintent-filter android:icon=\"drawable resource\"\n android:label=\"string resource\"\n android:priority=\"integer\" \u003e\n ...\n \u003c/intent-filter\u003e\n ```\n\ncontained in:\n: [\u003cactivity\u003e](/guide/topics/manifest/activity-element)\n\n [\u003cactivity-alias\u003e](/guide/topics/manifest/activity-alias-element)\n\n [\u003cservice\u003e](/guide/topics/manifest/service-element)\n\n [\u003creceiver\u003e](/guide/topics/manifest/receiver-element)\n\n [\u003cprovider\u003e](/guide/topics/manifest/provider-element)\n\nmust contain:\n: [\u003caction\u003e](/guide/topics/manifest/action-element)\n\ncan contain:\n: [\u003ccategory\u003e](/guide/topics/manifest/category-element)\n\n [\u003cdata\u003e](/guide/topics/manifest/data-element)\n\n [\u003curi-relative-filter-group\u003e](/guide/topics/manifest/uri-relative-filter-group-element)\n\ndescription:\n\n: Specifies the types of intents that an activity, service, or broadcast receiver can respond to. An intent filter declares the capabilities of its parent component: what an activity or service can do and what types of broadcasts a receiver can handle.\u003cbr /\u003e\n\n It opens the component to receiving\n intents of the advertised type while filtering out those that aren't\n meaningful for the component.\n Most of the contents of the filter are described by its subelements:\n\n - [\u003caction\u003e](/guide/topics/manifest/action-element),\n - [\u003ccategory\u003e](/guide/topics/manifest/category-element),\n - [\u003cdata\u003e](/guide/topics/manifest/data-element), and\n - [\u003curi-relative-filter-group\u003e](/guide/topics/manifest/uri-relative-filter-group-element).\n\n \u003cbr /\u003e\n\n\n For a more detailed discussion of filters, see\n [Intents\n and Intent Filters](/guide/components/intents-filters) and the\n [Intent filters](/guide/topics/manifest/manifest-intro#ifs)\n section in the app manifest overview.\n\nattributes:\n:\n\n `android:icon`\n\n : An icon that represents the parent activity, service, or broadcast receiver when that component is presented to the user as having the capability described by the filter.\u003cbr /\u003e\n\n\n This attribute is set as a reference to a drawable resource\n containing the image definition. The default value is the icon set\n by the parent component's `icon` attribute. If the parent\n doesn't specify an icon, the default is the icon set by the\n [\u003capplication\u003e](/guide/topics/manifest/application-element) element.\n\n\n For more information about intent filter icons, see the\n [Icons and labels](/guide/topics/manifest/manifest-intro#iconlabel)\n section in the app manifest overview.\n\n `android:label`\n\n : A user-readable label for the parent component. This label, rather than the one set by the parent component, is used when the component is presented to the user as having the capability described by the filter.\u003cbr /\u003e\n\n\n The label is set as a reference to a string resource so that\n it can be localized like other strings in the user interface.\n However, as a convenience while you're developing the application,\n it can also be set as a raw string.\n\n\n The default value is the label set by the parent component. If the\n parent doesn't specify a label, the default is the label set by the\n [\u003capplication\u003e](/guide/topics/manifest/application-element) element's\n [label](/guide/topics/manifest/application-element#label) attribute.\n\n\n For more information about intent filter labels, see the\n [Icons and labels](/guide/topics/manifest/manifest-intro#iconlabel)\n section in the app manifest overview.\n\n `android:priority`\n : The priority given to the parent component with regard\n to handling intents of the type described by the filter. This attribute has\n meaning for both activities and broadcast receivers.\n\n - It provides information about how able an activity is to respond to an intent that matches the filter, relative to other activities that can also respond to the intent. When an intent can be handled by multiple activities with different priorities, Android considers only those with higher priority values as potential targets for the intent.\n - It controls the order in which broadcast receivers are executed to\n receive broadcast messages, with those having higher priority\n values being called before those having lower values. The order applies only\n to synchronous messages. It's ignored for asynchronous messages.\n\n\n Use this attribute only if you need to impose a specific order in\n which the broadcasts are received or want to force Android to prefer\n one activity over others.\n\n\n The value is an integer, such as `100`. Higher numbers have a\n higher priority. The default value is `0`.\n\n\n In certain circumstances the requested priority is ignored and the value\n is capped to `0`. This occurs when:\n\n - A non-privileged application requests any priority \\\u003e0.\n - A privileged application requests a priority \\\u003e0 for [ACTION_VIEW](/reference/android/content/Intent#ACTION_VIEW), [ACTION_SEND](/reference/android/content/Intent#ACTION_SEND), [ACTION_SENDTO](/reference/android/content/Intent#ACTION_SENDTO) or [ACTION_SEND_MULTIPLE](/reference/android/content/Intent#ACTION_SEND_MULTIPLE).\n\n\n For more information, see [setPriority()](/reference/android/content/IntentFilter#setPriority(int)).\n\n `android:order`\n\n : The order in which the filter is processed when multiple filters match.\n\n `order` differs from `priority` in that `priority` applies\n across apps, while `order` disambiguates multiple matching filters in a single\n app.\n\n When multiple filters can match, use a directed intent instead.\n\n The value is an integer, such as `100`. Higher numbers are matched first.\n The default value is `0`.\n\n This attribute was introduced in API level 28.\n\n `android:autoVerify`\n : Whether Android needs to verify that the Digital Asset Links JSON file from the specified\n host matches this application.\n\nintroduced in:\n: API level 1\n\nsee also:\n: [\u003caction\u003e](/guide/topics/manifest/action-element)\n\n [\u003ccategory\u003e](/guide/topics/manifest/category-element)\n\n [\u003cdata\u003e](/guide/topics/manifest/data-element)\n\n [\u003curi-relative-filter-group\u003e](/guide/topics/manifest/uri-relative-filter-group-element)"]]