- cú pháp:
<permission-tree android:icon="drawable resource" android:label="string resource" android:name="string" />
- có trong:
<manifest>
- mô tả:
- Khai báo tên cơ sở (base name) cho cây quyền. Ứng dụng này sở hữu tất cả tên trong cây. Ứng dụng này có thể tự động thêm các quyền mới vào cây bằng cách gọi
PackageManager.addPermission()
. Tên trong cây được phân tách bằng dấu chấm (".
"). Ví dụ: nếu tên cơ sở làcom.example.project.taxes
, thì các quyền như sau có thể được thêm vào:com.example.project.taxes.CALCULATE
com.example.project.taxes.deductions.STORE_RECEIPTS
com.example.project.taxes.deductions.ACCESS_RECORDS
Phần tử này không khai báo một quyền cụ thể mà chỉ là một không gian tên nơi có thể đặt các quyền. Để biết thêm thông tin về việc khai báo quyền, hãy xem phần tử
<permission>
. - thuộc tính:
android:icon
- Một biểu tượng thể hiện tất cả quyền trong cây. Thuộc tính này phải được đặt làm giá trị tham chiếu đến một tài nguyên có thể vẽ chứa định nghĩa hình ảnh.
android:label
- Tên nhóm dễ đọc đối với người dùng. Để thuận tiện, bạn có thể đặt nhãn trực tiếp ở dạng chuỗi thô trong quá trình phát triển. Tuy nhiên, khi ứng dụng sẵn sàng để xuất bản, hãy đặt nhãn này ở dạng tham chiếu đến một tài nguyên chuỗi, cho phép bản địa hoá nhãn này như các chuỗi khác trong giao diện người dùng.
android:name
- Tên ở gốc cây quyền. Tên này đóng vai trò là tiền tố cho tất cả tên quyền trong cây. Hãy dùng phạm vi kiểu Java để đảm bảo tên là riêng biệt. Tên phải có nhiều hơn 2 phân đoạn được phân tách bằng dấu chấm trong đường dẫn. Ví dụ:
com.example.base
là OK, nhưngcom.example
thì không.
- ra mắt từ:
- API cấp 1
- xem thêm:
<permission>
<permission-group>
<uses-permission>
<cây-quyền>
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,["# <permission-tree\u003e\n\nsyntax:\n:\n\n ```xml\n \u003cpermission-tree android:icon=\"drawable resource\"\n android:label=\"string resource\"\n android:name=\"string\" /\u003e\n ```\n\ncontained in:\n: [\u003cmanifest\u003e](/guide/topics/manifest/manifest-element)\n\ndescription:\n: Declares the base name for a tree of permissions. The application takes\n ownership of all names within the tree. It can dynamically add new permissions\n to the tree by calling [PackageManager.addPermission()](/reference/android/content/pm/PackageManager#addPermission(android.content.pm.PermissionInfo)).\n Names within the tree are separated by\n periods ('`.`'). For example, if the base name is\n `com.example.project.taxes`, permissions like the following might be\n added:\n\n `com.example.project.taxes.CALCULATE`\n\n `com.example.project.taxes.deductions.STORE_RECEIPTS`\n\n `com.example.project.taxes.deductions.ACCESS_RECORDS`\n\n\n This element doesn't declare a permission itself, only a\n namespace in which permissions can be placed. For more information about declaring permissions, see the\n [\u003cpermission\u003e](/guide/topics/manifest/permission-element)\n element.\n\nattributes:\n:\n\n `android:icon`\n : An icon representing all the permissions in the tree. This attribute\n must be set as a reference to a drawable resource containing the image\n definition.\n\n `android:label`\n : A user-readable name for the group. As a convenience, the label\n can be directly set as a raw string during development. However,\n when the application is ready to be published, set it as a\n reference to a string resource, so that it can be localized like other\n strings in the user interface.\n\n `android:name`\n : The name at the base of the permission tree. It serves as\n a prefix to all permission names in the tree. Use Java-style scoping\n so that the name is unique. The name must have more than\n two period-separated segments in its path. For example,\n `com.example.base` is OK, but `com.example` isn't.\n\nintroduced in:\n: API level 1\n\nsee also:\n: [\u003cpermission\u003e](/guide/topics/manifest/permission-element)\n\n [\u003cpermission-group\u003e](/guide/topics/manifest/permission-group-element)\n\n [\u003cuses-permission\u003e](/guide/topics/manifest/uses-permission-element)"]]