- 語法:
<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>
- 說明:
- 指定活動、服務或廣播接收器可回應的意圖類型。意圖篩選器會宣告其父項元件的功能,包括活動或服務可執行的作業,以及接收器可處理的廣播類型。
此外,意圖篩選器會開啟元件來接收通告類型的意圖,同時過濾對元件而言沒有意義的意圖。篩選器的大部分內容都是由其子元素來描述:
- 屬性:
android:icon
- 當系統向使用者提供特定元件,指出該元件具有篩選器所描述的功能時,就會顯示這個圖示代表父項活動、服務或廣播接收器。
這項屬性會設為包含圖片定義的可繪製資源參照。預設值是父項元件的
icon
屬性所設定的圖示。如果父項未指定圖示,則預設值為<application>
元素所設定的圖示。如要進一步瞭解意圖篩選器圖示,請參閱「應用程式資訊清單總覽」中的「圖示和標籤」一節。
android:label
- 使用者能夠理解的父項元件標籤。當系統向使用者提供特定元件,指出該元件具有篩選器所描述的功能時,就會使用這個標籤 (而非父項元件設定的標籤)。
這個標籤應設為字串資源的參照,這樣才能像使用者介面中的其他字串一樣進行本地化。不過為了方便起見,您也可以在開發應用程式時將其設為原始字串。
預設值為父項元件所設定的標籤。如果父項未指定標籤,則預設值為
<application>
元素的label
屬性所設定的標籤。如要進一步瞭解意圖篩選器標籤,請參閱「應用程式資訊清單總覽」中的「圖示和標籤」一節。
android:priority
- 為父項元件指定優先順序,讓系統據以處理篩選器所描述類型的意圖。這個屬性對活動和廣播接收器具有以下意義:
- 提供相關資訊,說明相對於其他也能回應意圖的活動,特定活動對於符合篩選器的意圖所具有的回應能力。如果意圖能由不同優先順序的多個活動處理,Android 只會將優先順序值較高的活動視為潛在的意圖目標。
控制接收廣播訊息時的廣播接收器執行順序,系統會先呼叫優先順序值較高的接收器,再呼叫較低值的接收器。這個順序僅適用於同步訊息。如果是非同步訊息,系統會忽略這個順序。
只有在需要依特定順序接收廣播訊息,或是想強制 Android 優先採用特定活動時,才應使用這項屬性。
這個值是整數,例如
100
。數字越大,表示優先順序越高。預設值為0
。在某些情況下,系統會忽略要求的優先順序,並將值限制在
0
。這類情況包括:- 沒有特殊權限的應用程式要求任何 >0 的優先順序。
- 具有特殊權限的應用程式為
ACTION_VIEW
、ACTION_SEND
、ACTION_SENDTO
或ACTION_SEND_MULTIPLE
要求 >0 的優先順序。
詳情請參閱
setPriority()
的說明。 android:order
指定在符合多個篩選器時,處理篩選器的順序。
order
與priority
的差別在於priority
會套用至所有應用程式,order
則可區分單一應用程式的多個相符篩選器。如果能符合多個篩選條件,請改為使用引導式意圖。
這個值是整數,例如
100
。系統會先處理數字較大的篩選器。預設值為0
。這項屬性是在 API 級別 28 中導入。
android:autoVerify
- Android 是否需要驗證指定主機提供的 Digital Asset Links JSON 檔案與這個應用程式相符。
詳情請參閱「驗證 Android 應用程式連結」一文。
預設值為
false
。這項屬性是在 API 級別 23 中導入。
- 導入版本:
- API 級別 1
- 另請參閱:
<action>
<category>
<data>
<uri-relative-filter-group>
<意圖篩選器>
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-07-27 (世界標準時間)。
[null,null,["上次更新時間:2025-07-27 (世界標準時間)。"],[],[],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)"]]