- cú pháp:
<activity-alias android:enabled=["true" | "false"] android:exported=["true" | "false"] android:icon="drawable resource" android:label="string resource" android:name="string" android:permission="string" android:targetActivity="string" > ... </activity-alias>
- có trong:
<application>
- có thể chứa:
<intent-filter>
<meta-data>
- mô tả:
- Bí danh của một hoạt động, do thuộc tính
targetActivity
đặt. Mục tiêu và bí danh phải ở trong cùng một ứng dụng và được khai báo trước bí danh đó trong tệp kê khai.Bí danh biểu thị hoạt động mục tiêu dưới dạng một thực thể độc lập và có thể có một tập hợp các bộ lọc ý định riêng. Bí danh chứ không phải là bộ lọc ý định trên chính hoạt động mục tiêu giúp xác định ý định nào có thể kích hoạt mục tiêu thông qua bí danh và cách hệ thống xử lý bí danh.
Chẳng hạn, các bộ lọc ý định trên bí danh có thể chỉ định cờ "
"android.intent.action.MAIN"
" và cờ ""android.intent.category.LAUNCHER"
", khiến bí danh được biểu thị trong trình chạy ứng dụng, mặc dù không có bộ lọc nào trên hoạt động mục tiêu sẽ tự thiết lập các cờ này.Ngoại trừ
targetActivity
, các thuộc tính<activity-alias>
là một tập hợp con của các thuộc tính<activity>
. Đối với các thuộc tính trong tập hợp con, không có giá trị nào được thiết lập dành cho mục tiêu chuyển sang bí danh. Tuy nhiên, đối với các thuộc tính không thuộc tập hợp con, các giá trị được thiết lập dành cho hoạt động mục tiêu cũng áp dụng cho bí danh. - thuộc tính:
android:enabled
- Liệu hệ thống có thể tạo thực thể cho hoạt động mục tiêu thông qua bí danh này hay không.
"true"
nếu có thể và"false"
nếu không thể. Giá trị mặc định là"true"
.Phần tử
<application>
có thuộc tínhenabled
riêng áp dụng cho tất cả các thành phần của ứng dụng, bao gồm cả các bí danh của hoạt động. Cả hai thuộc tính<application>
và<activity-alias>
phải là"true"
để hệ thống có thể tạo thực thể cho hoạt động mục tiêu thông qua bí danh. Nếu là"false"
, bí danh sẽ không hoạt động. android:exported
- Liệu thành phần của các ứng dụng khác có thể chạy hoạt động mục tiêu thông qua bí danh này hay không.
"true"
nếu có thể và"false"
nếu không thể. Nếu là"false"
, hoạt động mục tiêu chỉ có thể được chạy thông qua bí danh bằng các thành phần của cùng một ứng dụng với bí danh hoặc các ứng dụng có cùng mã nhận dạng người dùng.Giá trị mặc định này tuỳ thuộc vào việc bí danh có chứa các bộ lọc ý định hay không. Nếu không có bất kỳ bộ lọc nào thì bạn chỉ có thể gọi hoạt động mục tiêu thông qua bí danh bằng cách chỉ định tên chính xác của bí danh. Điều này có nghĩa là bí danh chỉ dành cho mục đích sử dụng nội bộ trong ứng dụng vì những ứng dụng khác không biết tên của bí danh. Vì vậy, giá trị mặc định là
"false"
. Mặt khác, sự hiện diện của ít nhất một bộ lọc ngụ ý rằng bí danh dành cho mục đích sử dụng bên ngoài, vì vậy giá trị mặc định là"true"
. android:icon
- Biểu tượng của hoạt động mục tiêu khi được biểu thị cho người dùng thông qua bí danh.
Để biết thêm thông tin, hãy xem thuộc tính
icon
của phần tử<activity>
. android:label
- Nhãn (mà người dùng có thể đọc được) của bí danh, khi được biểu thị cho người dùng thông qua bí danh.
Để biết thêm thông tin, hãy xem thuộc tính
label
của phần tử<activity>
. android:name
- Tên duy nhất dành cho bí danh. Tên giống với tên lớp đủ điều kiện. Nhưng, không giống với tên của hoạt động mục tiêu, tên bí danh là tuỳ ý. Đây không phải là một lớp thực tế.
android:permission
- Tên của một quyền mà ứng dụng khách phải có để chạy hoạt động mục tiêu hoặc yêu cầu mục tiêu thực hiện một hoạt động nào đó bằng bí danh. Nếu phương thức gọi của
startActivity()
hoặcstartActivityForResult()
không được cấp quyền đã chỉ định, thì hoạt động mục tiêu sẽ không được kích hoạt.Thuộc tính này thay thế cho bất kỳ quyền nào được thiết lập đối với chính hoạt động mục tiêu. Nếu chưa đặt chính sách này, thì bạn không cần cấp quyền để kích hoạt mục tiêu thông qua bí danh.
Để biết thêm thông tin về các quyền, hãy xem phần Quyền trong phần tổng quan về tệp kê khai ứng dụng.
android:targetActivity
- Tên của hoạt động có thể được kích hoạt thông qua bí danh.
Tên này phải khớp với thuộc tính
name
của một phần tử<activity>
đứng trước bí danh đó trong tệp kê khai.
- ra mắt từ:
- API cấp 1
- xem thêm:
<activity>
<activity-alias>
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,["# <activity-alias\u003e\n\nsyntax:\n:\n\n ```xml\n \u003cactivity-alias android:enabled=[\"true\" | \"false\"]\n android:exported=[\"true\" | \"false\"]\n android:icon=\"drawable resource\"\n android:label=\"string resource\"\n android:name=\"string\"\n android:permission=\"string\"\n android:targetActivity=\"string\" \u003e\n ...\n \u003c/activity-alias\u003e\n ```\n\ncontained in:\n: [\u003capplication\u003e](/guide/topics/manifest/application-element)\n\ncan contain:\n: [\u003cintent-filter\u003e](/guide/topics/manifest/intent-filter-element)\n\n [\u003cmeta-data\u003e](/guide/topics/manifest/meta-data-element)\n\ndescription:\n: An alias for an activity, named by the `targetActivity`\n attribute. The target must be in the same application as the\n alias and declared before the alias in the manifest.\n\n\n The alias presents the target activity as an independent entity, and can have its own set of intent\n filters. They, rather than the\n intent filters on the target activity itself, determine which intents\n can activate the target through the alias and how the system\n treats the alias.\n\n For example, the intent filters on the alias might\n specify the [\"android.intent.action.MAIN\"](/reference/android/content/Intent#ACTION_MAIN)\n and [\"android.intent.category.LAUNCHER\"](/reference/android/content/Intent#CATEGORY_LAUNCHER)\" flags, causing it to\n be represented in the application launcher, even though none of the\n filters on the target activity itself set these flags.\n\n\n With the exception of `targetActivity`, `\u003cactivity-alias\u003e`\n attributes are a subset of [\u003cactivity\u003e](/guide/topics/manifest/activity-element) attributes.\n For attributes in the subset, none of the values set for the target carry over\n to the alias. However, for attributes not in the subset, the values set for\n the target activity also apply to the alias.\n\nattributes:\n:\n\n `android:enabled`\n : Whether the target activity can be instantiated by the system through\n this alias. `\"true\"` if it can be, and `\"false\"` if not.\n The default value is `\"true\"`.\n\n\n The [\u003capplication\u003e](/guide/topics/manifest/application-element) element has its own\n [enabled](/guide/topics/manifest/application-element#enabled) attribute that applies to all\n application components, including activity aliases. The\n `\u003capplication\u003e` and `\u003cactivity-alias\u003e`\n attributes must both be `\"true\"` for the system to be able to instantiate\n the target activity through the alias. If either is `\"false\"`, the alias\n doesn't work.\n\n `android:exported`\n : Whether the components of other applications can launch the target activity\n through this alias. `\"true\"` if they can, and `\"false\"` if not.\n If `\"false\"`, the target activity can be launched through the alias only by\n components of the same application as the alias or applications with the same user ID.\n\n\n The default value depends on whether the alias contains intent filters. The\n absence of any filters means that the activity can be invoked through the alias\n only by specifying the exact name of the alias. This implies that the alias\n is intended only for application-internal use, since others don't know its name.\n So, the default value is `\"false\"`.\n On the other hand, the presence of at least one filter implies that the alias\n is intended for external use, so the default value is `\"true\"`.\n\n `android:icon`\n : An icon for the target activity when presented to users through the alias.\n For more information, see the [\u003cactivity\u003e](/guide/topics/manifest/activity-element) element's\n [icon](/guide/topics/manifest/activity-element#icon) attribute.\n\n `android:label`\n : A user-readable label for the alias when presented to users through the alias.\n For more information, see the [\u003cactivity\u003e](/guide/topics/manifest/activity-element) element's\n [label](/guide/topics/manifest/activity-element#label) attribute.\n\n \u003cbr /\u003e\n\n `android:name`\n\n : A unique name for the alias. The name resembles a fully qualified class name. But, unlike the name of the target activity, the alias name is arbitrary. It doesn't refer to an actual class. \u003cbr /\u003e\n\n `android:permission`\n : The name of a permission that clients must have to launch the target activity\n or get it to do something using the alias. If a caller of\n [startActivity()](/reference/android/content/Context#startActivity(android.content.Intent)) or\n [startActivityForResult()](/reference/android/app/Activity#startActivityForResult(android.content.Intent, int))\n isn't granted the specified permission, the target activity isn't activated.\n\n This attribute supplants any permission set for the target activity itself. If\n it isn't set, a permission isn't needed to activate the target through the alias.\n\n\n For more information about permissions, see the\n [Permissions](/guide/topics/manifest/manifest-intro#perms)\n section in the app manifest overview.\n\n `android:targetActivity`\n : The name of the activity that can be activated through the alias.\n This name must match the `name` attribute of an\n [\u003cactivity\u003e](/guide/topics/manifest/activity-element) element that precedes\n the alias in the manifest.\n\n \u003cbr /\u003e\n\nintroduced in:\n: API level 1\n\nsee also:\n: [\u003cactivity\u003e](/guide/topics/manifest/activity-element)"]]