- składnia:
<permission android:description="string resource" android:icon="drawable resource" android:label="string resource" android:name="string" android:permissionGroup="string" android:protectionLevel=["normal" | "dangerous" | "signature" | ...] />
- zawarte w:
<manifest>
- description:
- Deklaruje uprawnienia związane z bezpieczeństwem używane do: ograniczyć dostęp do określonych komponentów lub funkcji tej lub innych aplikacji. Więcej informacji o tym, jak działają uprawnienia, znajdziesz w sekcji Uprawnienia w omówieniu pliku manifestu aplikacji i w sekcji Wskazówki dotyczące bezpieczeństwa.
- atrybuty:
android:description
- Czytelny dla użytkownika opis uprawnień, dłuższy i dłuższy
niż etykieta. Może ona na przykład wyświetlać wyjaśnienie
gdy użytkownik zostanie poproszony o zgodę.
aby przyznać je innej aplikacji.
Ten atrybut jest ustawiony jako odwołanie do zasobu ciągu znaków. W przeciwieństwie do atrybutu
label
nie może to być nieprzetworzony ciąg znaków. android:icon
- Odniesienie do rysowalnego zasobu dla ikony reprezentującej uprawnienia.
android:label
- Czytelna dla użytkownika nazwa uprawnienia.
Dla wygody etykietę można ustawić bezpośrednio jako nieprzetworzony ciąg znaków w trakcie programowania aplikacji. Pamiętaj jednak: gdy aplikacja jest gotowa do publikacji, ustaw ją jako odwołanie do zasobu w postaci ciągu, aby można je było zlokalizować w taki sam sposób jak inne ciągi tekstowe w interfejsie.
android:name
- Nazwa, która będzie używana w
kodu odwołującego się do uprawnienia, np.
<uses-permission>
lub Atrybutypermission
komponentów aplikacji.Uwaga: system nie zezwala na deklarowanie wielu pakietów. uprawnienia o tej samej nazwie, chyba że wszystkie pakiety są podpisane ten sam certyfikat. Jeśli pakiet deklaruje uprawnienia, system nie zezwala użytkownik może zainstalować inne pakiety z tą samą nazwą uprawnienia, chyba że te pakiety są podpisane tym samym certyfikatem co pierwszy pakiet.
Z tego powodu Google zaleca, aby uprawnienia były poprzedzone nazwą pakietu aplikacji, za pomocą odwrotnych nazw domenowych. Stosuj się do tego prefiksu prefiksem
.permission.
, a potem dodaj opis funkcja reprezentowana przez uprawnienie w górnej części SNAKE_CASE. Na przykład:com.example.myapp.permission.ENGAGE_HYPERSPACE
Przestrzeganie tej zalecenia pozwala uniknąć konfliktów w nazwach i łatwiej zidentyfikować właściciela. i celu niestandardowego.
android:permissionGroup
- Przypisuje to uprawnienie grupie. Wartość tego atrybutu to
nazwa grupy, która jest zadeklarowana za pomocą
<permission-group>
element lub innej aplikacji. Jeśli ten atrybut nie jest skonfigurowany, uprawnienia nie należy do grupy. android:protectionLevel
-
Opisuje potencjalne ryzyko wynikające z uprawnień i wskazuje procedurę, którą system ma zastosować przy określaniu czy udzielić uprawnień aplikacji, która o nie prosi.
Każdy poziom ochrony składa się z podstawowego typu uprawnień i z co najmniej 0 poziomów uprawnień. flagami. Na przykład poziom ochrony
"dangerous"
nie zawiera flagami. Z kolei poziom ochrony"signature|privileged"
to połączenie podstawowego typu uprawnień"signature"
i Flaga"privileged"
.W tabeli poniżej znajdziesz wszystkie podstawowe typy uprawnień. Listę flag znajdziesz tu
protectionLevel
Wartość Znaczenie "normal"
Wartość domyślna. Uprawnienie o mniejszym ryzyku, które umożliwia wysyłanie próśb dostęp aplikacji do izolowanych funkcji na poziomie aplikacji za pomocą dla innych aplikacji, systemu lub użytkownika. System automatycznie przyznaje ten typ aplikacji wysyłającej żądanie podczas instalacji, bez prosi o wyraźną zgodę użytkownika, chociaż zawsze może sprawdzić te uprawnienia przed instalacją. "dangerous"
Uprawnienie o wyższym ryzyku, które przyznaje aplikacji żądającej dostępu dostępu do prywatnych danych użytkownika lub kontroli nad urządzeniem, które może mogą negatywnie wpłynąć na użytkownika. Ponieważ tego typu uprawnienia stwarza potencjalne ryzyko, system może nie automatycznie udzielenie jej adresowi zgłoszeniowego. Na przykład niebezpieczne uprawnienia, których żąda aplikacja, mogą być wyświetlane użytkownika i wymagają potwierdzenia przed kontynuacją, lub w inny można zastosować metodę unikania automatycznego przyznawania korzystanie z takich obiektów. "signature"
Uprawnienie przyznane przez system tylko wtedy, gdy żądanie aplikacja jest podpisana tym samym certyfikatem co aplikacja w którym zadeklarowano uprawnienia. Jeśli certyfikaty są zgodne, system automatycznie przyzna uprawnienia bez powiadamiania użytkownika lub z prośbą o wyraźną zgodę użytkownika. "knownSigner"
Uprawnienie przyznane przez system tylko wtedy, gdy żądanie aplikacja jest podpisana przez dozwolony certyfikat. Jeśli certyfikat żądającego znajduje się na liście, system automatycznie przyzna uprawnienia bez powiadamiania użytkownika lub z prośbą o wyraźną zgodę użytkownika. "signatureOrSystem"
Stary synonim słowa
"signature|privileged"
. Wycofano w interfejsie API poziom 23.Uprawnienie przyznawane przez system tylko tym aplikacjom, które w specjalnym folderze w obrazie systemu Android lub jest podpisane tym samym certyfikatem co aplikacja, która zadeklarowała uprawnienia. Unikaj korzystania z tej opcji, ponieważ
"signature"
poziom ochrony jest wystarczający dla większości potrzeb i działa niezależnie gdzie są zainstalowane aplikacje."signatureOrSystem"
– określone uprawnienia specjalne w sytuacjach, gdy wielu dostawców ma wbudowane aplikacje w system. i muszą wyraźnie udostępniać określone cechy, razem z innymi.
- wprowadzone w:
- Poziom API 1
- zobacz też:
<uses-permission>
<permission-tree>
<permission-group>
<uprawnienia>
Treść strony i umieszczone na niej fragmenty kodu podlegają licencjom opisanym w Licencji na treści. Java i OpenJDK są znakami towarowymi lub zastrzeżonymi znakami towarowymi należącymi do firmy Oracle lub jej podmiotów stowarzyszonych.
Ostatnia aktualizacja: 2025-07-27 UTC.
[[["Łatwo zrozumieć","easyToUnderstand","thumb-up"],["Rozwiązało to mój problem","solvedMyProblem","thumb-up"],["Inne","otherUp","thumb-up"]],[["Brak potrzebnych mi informacji","missingTheInformationINeed","thumb-down"],["Zbyt skomplikowane / zbyt wiele czynności do wykonania","tooComplicatedTooManySteps","thumb-down"],["Nieaktualne treści","outOfDate","thumb-down"],["Problem z tłumaczeniem","translationIssue","thumb-down"],["Problem z przykładami/kodem","samplesCodeIssue","thumb-down"],["Inne","otherDown","thumb-down"]],["Ostatnia aktualizacja: 2025-07-27 UTC."],[],[],null,["# <permission\u003e\n\nsyntax:\n:\n\n ```xml\n \u003cpermission android:description=\"string resource\"\n android:icon=\"drawable resource\"\n android:label=\"string resource\"\n android:name=\"string\"\n android:permissionGroup=\"string\"\n android:protectionLevel=[\"normal\" | \"dangerous\" |\n \"signature\" | ...] /\u003e\n ```\n\ncontained in:\n: [\u003cmanifest\u003e](/guide/topics/manifest/manifest-element)\n\ndescription:\n: Declares a security permission used to\n limit access to specific components or features of this or other applications.\n For more information about how permissions work, see the [Permissions](/guide/topics/manifest/manifest-intro#perms) section in the app manifest overview and [Security tips](/guide/topics/security/security).\n\nattributes:\n:\n\n `android:description`\n\n : A user-readable description of the permission that is longer and more informative than the label. It might display, for example, to explain the permission to the user when the user is asked to grant the permission to another application.\u003cbr /\u003e\n\n\n This attribute is set as a reference to a string resource.\n Unlike the `label` attribute, it can't be a raw string.\n\n `android:icon`\n : A reference to a drawable resource for an icon that represents the\n permission.\n\n `android:label`\n\n : A user-readable name for the permission.\u003cbr /\u003e\n\n\n As a convenience, the label can be directly set\n as a raw string while you're developing the application. However,\n when the application is ready to publish, 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 to be used in\n code to refer to the permission, such as in a\n [\u003cuses-permission\u003e](/guide/topics/manifest/uses-permission-element) element or the\n `permission` attributes of application components.\n\n\n **Note:** The system doesn't let multiple packages declare\n a permission with the same name unless all the packages are signed with the\n same certificate. If a package declares a permission, the system doesn't permit\n the user to install other packages with the same permission name, unless\n those packages are signed with the same certificate as the first package.\n\n For this reason, Google recommends prefixing permissions with the app's package name,\n using reverse-domain-style naming.\n Follow this prefix with `.permission.` and then a description of the\n capability that the permission represents in upper SNAKE_CASE. For example:\n `com.example.myapp.permission.ENGAGE_HYPERSPACE`.\n\n Following this recommendation avoids naming collisions and helps clearly identify the owner\n and intention of a custom permission.\n\n `android:permissionGroup`\n : Assigns this permission to a group. The value of this attribute is\n the name of the group, which is declared with the\n [\u003cpermission-group\u003e](/guide/topics/manifest/permission-group-element) element in this\n or another application. If this attribute isn't set, the permission\n doesn't belong to a group.\n\n `android:protectionLevel`\n\n :\n Characterizes the potential risk implied in the permission and\n indicates the procedure for the system to follow when determining\n whether to grant the permission to an application requesting it.\n\n\n Each protection level consists of a base permission type and zero or more\n flags. For example, the `\"dangerous\"` protection level has no\n flags. In contrast, the protection level `\"signature|privileged\"`\n is a combination of the `\"signature\"` base permission type and the\n `\"privileged\"` flag.\n\n\n The following table shows all base permission types. For a list of flags, see\n [protectionLevel](/reference/android/R.attr#protectionLevel).\n\n | Value | Meaning |\n |-----------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n | `\"normal\"` | The default value. A lower-risk permission that gives requesting applications access to isolated application-level features with minimal risk to other applications, the system, or the user. The system automatically grants this type of permission to a requesting application at installation, without asking for the user's explicit approval, though the user always has the option to review these permissions before installing. |\n | `\"dangerous\"` | A higher-risk permission that gives a requesting application access to private user data or control over the device that can negatively impact the user. Because this type of permission introduces potential risk, the system might not automatically grant it to the requesting application. For example, any dangerous permissions requested by an application might be displayed to the user and require confirmation before proceeding, or some other approach might be taken to avoid the user automatically granting the use of such facilities. |\n | `\"signature\"` | A permission that the system grants only if the requesting application is signed with the same certificate as the application that declared the permission. If the certificates match, the system automatically grants the permission without notifying the user or asking for the user's explicit approval. |\n | `\"knownSigner\"` | A permission that the system grants only if the requesting application is signed with [an allowed certificate](/guide/topics/permissions/defining#grant-signature-permissions). If the requester's certificate is listed, the system automatically grants the permission without notifying the user or asking for the user's explicit approval. |\n | `\"signatureOrSystem\"` | *Old synonym for `\"signature|privileged\"`. Deprecated in API level 23.* A permission that the system grants only to applications that are in a dedicated folder on the Android system image *or* that are signed with the same certificate as the application that declared the permission. Avoid using this option, as the `\"signature\"` protection level is sufficient for most needs and works regardless of where apps are installed. The `\"signatureOrSystem\"` permission is used for certain special situations where multiple vendors have applications built into a system image and need to share specific features explicitly because they are being built together. |\n\nintroduced in:\n: API level 1\n\nsee also:\n: [\u003cuses-permission\u003e](/guide/topics/manifest/uses-permission-element)\n\n [\u003cpermission-tree\u003e](/guide/topics/manifest/permission-tree-element)\n\n [\u003cpermission-group\u003e](/guide/topics/manifest/permission-group-element)"]]