- cú pháp:
<intent-filter android:icon="drawable resource" android:label="string resource" android:priority="integer" > ... </intent-filter>
- có trong:
<activity>
<activity-alias>
<service>
<receiver>
<provider>
- phải chứa:
<action>
- có thể chứa:
<category>
<data>
<uri-relative-filter-group>
- mô tả:
- Chỉ định loại ý định mà một hoạt động, dịch vụ hoặc broadcast receiver có thể phản hồi. Bộ lọc ý định khai báo chức năng của thành phần mẹ: những việc một hoạt động hoặc dịch vụ có thể làm và những loại hình truyền tin mà bộ nhận có thể xử lý.
Bộ lọc ý định này sẽ mở ra thành phần để nhận ý định của loại được quảng cáo, đồng thời lọc bỏ những thành phần không có ý nghĩa đối với thành phần này. Hầu hết nội dung của bộ lọc đều được mô tả qua các phần tử phụ:
Để thảo luận chi tiết hơn về các bộ lọc, hãy xem bài viết Ý định và bộ lọc ý định cũng như phần Bộ lọc ý định trên trang tổng quan về tệp kê khai ứng dụng.
- thuộc tính:
android:icon
- Một biểu tượng đại diện cho hoạt động, dịch vụ hoặc broadcast receiver mẹ khi thành phần đó hiển thị với người dùng do có chức năng mà bộ lọc mô tả.
Thuộc tính này được đặt làm tham chiếu đến một tài nguyên có thể vẽ và chứa định nghĩa hình ảnh. Giá trị mặc định là biểu tượng do thuộc tính
icon
của thành phần mẹ đặt. Nếu thành phần mẹ không chỉ định một biểu tượng, thì giá trị mặc định sẽ là biểu tượng do phần tử<application>
đặt.Để biết thêm thông tin về các biểu tượng của bộ lọc ý định, hãy xem phần Biểu tượng và nhãn trên trang tổng quan về tệp kê khai ứng dụng.
android:label
- Nhãn mà người dùng có thể đọc được cho thành phần mẹ. Nhãn này (thay vì một nhãn do thành phần mẹ đặt) sẽ được dùng khi thành phần này hiển thị với người dùng vì có chức năng mà bộ lọc mô tả.
Nhãn được đặt làm tham chiếu đến tài nguyên chuỗi để có thể được bản địa hoá như các chuỗi khác trong giao diện người dùng. Tuy nhiên, để thuận tiện trong quá trình phát triển ứng dụng, bạn cũng có thể đặt nhãn này làm chuỗi thô.
Giá trị mặc định là nhãn do thành phần mẹ đặt. Nếu thành phần mẹ không chỉ định một nhãn, thì giá trị mặc định sẽ là nhãn do thuộc tính
label
của phần tử<application>
đặt.Để biết thêm thông tin về các nhãn của bộ lọc ý định, hãy xem phần Biểu tượng và nhãn trên trang tổng quan về tệp kê khai ứng dụng.
android:priority
- Mức ưu tiên được cấp cho thành phần mẹ liên quan đến việc xử lý ý định thuộc loại mà bộ lọc mô tả. Thuộc tính này có ý nghĩa đối với cả hoạt động và broadcast receiver.
- Thuộc tính này cung cấp thông tin về khả năng một hoạt động phản hồi một ý định khớp với bộ lọc, so với các hoạt động khác cũng có thể phản hồi ý định đó. Khi một ý định có thể được xử lý bằng nhiều hoạt động ở mức độ ưu tiên khác nhau, Android sẽ chỉ xem xét những ý định có giá trị ưu tiên cao hơn làm mục tiêu tiềm năng cho ý định đó.
Thuộc tính này kiểm soát thứ tự thực thi broadcast receiver để nhận thông báo truyền tin, trong đó những thông báo có giá trị ưu tiên cao sẽ được gọi trước những thông báo có giá trị thấp hơn. Thứ tự này chỉ áp dụng cho các thông báo đồng bộ, chứ không áp dụng cho các thông báo không đồng bộ.
Chỉ dùng thuộc tính này nếu bạn cần áp dụng một thứ tự cụ thể cho nội dung truyền tin nhận được hoặc muốn buộc Android ưu tiên một hoạt động nào đó hơn các hoạt động khác.
Giá trị là một số nguyên, chẳng hạn như
100
. Số càng cao thì mức ưu tiên càng cao. Giá trị mặc định là0
.Trong một số trường hợp, mức độ ưu tiên đã yêu cầu sẽ bị bỏ qua và giá trị sẽ được giới hạn ở mức
0
. Điều này xảy ra khi:- Một ứng dụng không đặc quyền yêu cầu mức độ ưu tiên nào đó >0.
- Một ứng dụng đặc quyền yêu cầu mức độ ưu tiên >0 cho
ACTION_VIEW
,ACTION_SEND
,ACTION_SENDTO
hoặcACTION_SEND_MULTIPLE
.
Để biết thêm thông tin, hãy xem
setPriority()
. android:order
Thứ tự xử lý bộ lọc khi nhiều bộ lọc trùng khớp.
order
khác vớipriority
ở chỗpriority
áp dụng trên nhiều ứng dụng, trong khiorder
lại phân biệt nhiều bộ lọc trùng khớp trong một ứng dụng duy nhất.Khi có nhiều bộ lọc trùng khớp, hãy sử dụng một ý định được chỉ dẫn.
Giá trị là một số nguyên, chẳng hạn như
100
. Số cao hơn sẽ được so khớp trước. Giá trị mặc định là0
.Thuộc tính này được ra mắt trong API cấp 28.
android:autoVerify
- Liệu Android có cần xác minh để đảm bảo tệp JSON chứa Digital Asset Links (Đường liên kết đến tài sản kỹ thuật số) từ máy chủ lưu trữ đã chỉ định khớp với ứng dụng này hay không.
Để biết thêm thông tin, hãy xem bài viết Xác minh Đường liên kết trong ứng dụng Android.
Giá trị mặc định là
false
.Thuộc tính này được ra mắt trong API cấp 23.
- ra mắt từ:
- API cấp 1
- xem thêm:
<action>
<category>
<data>
<uri-relative-filter-group>
<intent-filter>
Nội dung và mã mẫu trên trang này phải tuân thủ các giấy phép như mô tả trong phần Giấy phép nội dung. Java và OpenJDK là nhãn hiệu hoặc nhãn hiệu đã đăng ký của Oracle và/hoặc đơn vị liên kết của Oracle.
Cập nhật lần gần đây nhất: 2025-07-27 UTC.
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 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)"]]