<hành động>
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
- cú pháp:
<action android:name="string" />
- có trong:
<intent-filter>
- mô tả:
- Thêm thao tác vào bộ lọc ý định.
Mỗi phần tử
<intent-filter>
phải chứa ít nhất một phần tử <action>
. Nếu không có phần tử <action>
trong bộ lọc ý định, thì bộ lọc này sẽ không chấp nhận các đối tượng Intent
.
Để biết thông tin chi tiết về bộ lọc ý định và vai trò của quy cách hành động trong một bộ lọc, hãy xem bài viết Ý định và bộ lọc ý định.
- thuộc tính:
android:name
- Tên thao tác. Một số thao tác chuẩn được xác định trong lớp
Intent
dưới dạng hằng số ACTION_string
. Để gán một trong những thao tác đó cho thuộc tính này, hãy thêm android.intent.action.
vào string
theo sau ACTION_
.
Ví dụ: dùng android.intent.action.MAIN
cho ACTION_MAIN
và android.intent.action.WEB_SEARCH
cho ACTION_WEB_SEARCH
.
Đối với thao tác mà bạn xác định, tốt hơn hết là bạn nên dùng tên gói ứng dụng làm tiền tố để đảm bảo tính riêng biệt. Ví dụ: thao tác TRANSMOGRIFY
có thể được chỉ định như sau:
<action android:name="com.example.project.TRANSMOGRIFY" />
- ra mắt từ:
- API cấp 1
- xem thêm:
<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,["# <action\u003e\n\nsyntax:\n:\n\n ```xml\n \u003caction android:name=\"string\" /\u003e\n ```\n\ncontained in:\n: [\u003cintent-filter\u003e](/guide/topics/manifest/intent-filter-element)\n\ndescription:\n: Adds an action to an intent filter.\n An [\u003cintent-filter\u003e](/guide/topics/manifest/intent-filter-element)\n element must contain one or more `\u003caction\u003e` elements. If there\n are no `\u003caction\u003e` elements in an intent filter, the filter\n doesn't accept any [Intent](/reference/android/content/Intent) objects.\n For details about intent filters and the role of action\n specifications within a filter, see\n [Intents and\n Intent Filters](/guide/components/intents-filters).\n\nattributes:\n:\n\n `android:name`\n : The name of the action. Some standard actions are defined in the\n [Intent](/reference/android/content/Intent#ACTION_CHOOSER) class as\n `ACTION_`*string* constants. To assign one of these actions to\n this attribute, prepend `android.intent.action.` to the\n *string* that follows `ACTION_`.\n For example, for `ACTION_MAIN`, use `android.intent.action.MAIN`,\n and for `ACTION_WEB_SEARCH`, use `android.intent.action.WEB_SEARCH`.\n\n\n For actions you define, it's best to use your app's package name as a prefix to\n help ensure uniqueness. For example, a `TRANSMOGRIFY` action might be specified\n as follows:\n\n\n ```xml\n \u003caction android:name=\"com.example.project.TRANSMOGRIFY\" /\u003e\n ```\n\nintroduced in:\n: API Level 1\n\nsee also:\n: [\u003cintent-filter\u003e](/guide/topics/manifest/intent-filter-element)"]]