- 语法:
<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>
- 说明:
- 指定 activity、服务或广播接收器可以响应的 intent 类型。intent 过滤器声明其父组件的功能:activity 或服务可执行哪些操作,以及接收器可处理哪些类型的广播。
它让组件可以接收所通告类型的 intent,同时过滤掉对组件没有意义的 intent。过滤器的大部分内容由它的子元素进行描述:
如需详细了解过滤器,请参阅 intent 和 intent 过滤器以及应用清单概览中的 intent 过滤器部分。
- 属性:
android:icon
- 一个表示父 activity、服务或广播接收器的图标,在将该组件以具备过滤器所描述功能的形式呈现给用户时显示。
此属性应设置为对包含图片定义的可绘制资源的引用。默认值为父组件的
icon
属性设置的图标。如果父组件未指定图标,则默认值为<application>
元素设置的图标。如需详细了解 intent 过滤器图标,请参阅应用清单概览中的图标和标签部分。
android:label
- 父组件的用户可读标签。将相应组件以具备过滤器所描述功能的形式呈现给用户时,将使用此标签(而不是父组件设置的标签)。
此标签应设置为对字符串资源的引用,以便可以像界面中的其他字符串一样进行本地化。不过,为了方便您开发应用,也可以将其设为原始字符串。
默认值为父组件设置的标签。如果父组件未指定标签,则默认值为
<application>
元素的label
属性设置的标签。如需详细了解 intent 过滤器标签,请参阅应用清单概览中的图标和标签部分。
android:priority
- 为父组件指定的优先级,以便系统据此处理过滤器所描述类型的 intent。此属性对 activity 和广播接收器都有意义。
- 它说明了某个 activity 对与过滤器匹配的 intent 的响应能力,这是相对于也可以响应该 intent 的其他 activity 的响应能力。当 intent 可由优先级不同的多个 activity 处理时,Android 只会将优先级值较高的 activity 视为 intent 的潜在目标。
该属性用于控制广播接收器接收广播消息的执行顺序,优先级值越高,调用顺序越靠前。该顺序仅适用于同步消息。对于异步消息,系统会忽略该顺序。
只有在您需要对接收广播施加特定顺序或想要强制 Android 优先选用某个 activity 时,才能使用此属性。
该值是一个整数,例如
100
。数值越高,优先级也就越高。默认值为0
。在某些情况下,系统会忽略请求的优先级,并将值限定为
0
。此类情况发生在:- 非特权应用请求任何大于 0 的优先级时。
- 特权应用为
ACTION_VIEW
、ACTION_SEND
、ACTION_SENDTO
或ACTION_SEND_MULTIPLE
请求大于 0 的优先级时。
如需了解详情,请参阅
setPriority()
。 android:order
当多个过滤器匹配时过滤器的处理顺序。
order
与priority
的不同之处在于,priority
在多个应用间应用,而order
可消除单个应用中多个匹配的过滤器的歧义。当多个过滤器可以匹配时,请改用定向 intent。
该值是一个整数,例如
100
。数值越高,匹配顺序越靠前。默认值为0
。此属性在 API 级别 28 中引入。
android:autoVerify
- Android 是否需要验证指定主机中的 Digital Asset Links JSON 文件与此应用的匹配情况。
如需了解详情,请参阅验证 Android App Links。
默认值为
false
。此属性在 API 级别 23 中引入。
- 引入于:
- API 级别 1
- 另请参阅:
<action>
<category>
<data>
<uri-relative-filter-group>
<意向过滤器>
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-27。
[null,null,["最后更新时间 (UTC):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)"]]