- نحو:
<permission android:description="string resource" android:icon="drawable resource" android:label="string resource" android:name="string" android:permissionGroup="string" android:protectionLevel=["normal" | "dangerous" | "signature" | ...] />
- موجود در:
-
<manifest>
- توضیحات:
- یک مجوز امنیتی را اعلام می کند که برای محدود کردن دسترسی به اجزا یا ویژگی های خاص این یا سایر برنامه ها استفاده می شود. برای اطلاعات بیشتر در مورد نحوه عملکرد مجوزها، به بخش مجوزها در نمای کلی مانیفست برنامه و نکات امنیتی مراجعه کنید.
- صفات:
-
android:description
- شرحی قابل خواندن از مجوز که طولانی تر و آموزنده تر از برچسب است. برای مثال، زمانی که از کاربر خواسته می شود مجوز را به برنامه دیگری بدهد، ممکن است نمایش داده شود.
این ویژگی به عنوان یک مرجع به یک منبع رشته تنظیم شده است. برخلاف ویژگی
label
، نمی تواند یک رشته خام باشد. -
android:icon
- ارجاع به یک منبع قابل ترسیم برای نمادی که نشان دهنده مجوز است.
-
android:label
- یک نام قابل خواندن توسط کاربر برای مجوز.
به عنوان یک راحتی، برچسب را می توان به طور مستقیم به عنوان یک رشته خام در حالی که شما در حال توسعه برنامه هستید تنظیم کنید. با این حال، هنگامی که برنامه آماده انتشار است، آن را به عنوان مرجع یک منبع رشته تنظیم کنید تا مانند رشته های دیگر در رابط کاربری بومی سازی شود.
-
android:name
- نامی که در کد برای اشاره به مجوز استفاده می شود، مانند عنصر
<uses-permission>
یا ویژگی هایpermission
اجزای برنامه.توجه: سیستم اجازه نمی دهد چندین بسته مجوزی با نام یکسان را اعلام کنند، مگر اینکه همه بسته ها با یک گواهی امضا شده باشند. اگر بسته ای مجوز را اعلام کند، سیستم به کاربر اجازه نمی دهد بسته های دیگری را با همان نام مجوز نصب کند، مگر اینکه آن بسته ها با همان گواهی بسته اول امضا شده باشند.
به همین دلیل، گوگل توصیه میکند که مجوزها را با نام بسته برنامه با استفاده از نامگذاری به سبک معکوس دامنه اضافه کنید. این پیشوند را با
.permission.
و سپس شرحی از قابلیتی که مجوز در SNAKE_CASE بالایی نشان می دهد. به عنوان مثال:com.example.myapp.permission.ENGAGE_HYPERSPACE
.پیروی از این توصیه از تداخل نامگذاری جلوگیری میکند و به شناسایی واضح مالک و قصد مجوز سفارشی کمک میکند.
-
android:permissionGroup
- این مجوز را به یک گروه اختصاص می دهد. مقدار این ویژگی نام گروه است که با عنصر
<permission-group>
در این یا برنامه دیگر اعلام می شود. اگر این ویژگی تنظیم نشده باشد، مجوز متعلق به یک گروه نیست. -
android:protectionLevel
خطر بالقوه مندرج در مجوز را مشخص می کند و روشی را نشان می دهد که سیستم باید هنگام تصمیم گیری برای اعطای مجوز به برنامه درخواست کننده آن، از آن پیروی کند.
هر سطح حفاظتی شامل یک نوع مجوز پایه و پرچم صفر یا بیشتر است. به عنوان مثال، سطح حفاظتی
"dangerous"
هیچ پرچمی ندارد. در مقابل، سطح حفاظتی"signature|privileged"
ترکیبی از نوع مجوز پایه"signature"
و پرچم"privileged"
است.جدول زیر تمام انواع مجوزهای پایه را نشان می دهد. برای لیستی از پرچم ها، به
protectionLevel
مراجعه کنید.ارزش معنی "normal"
مقدار پیش فرض یک مجوز کم خطر که به برنامههای درخواستکننده امکان دسترسی به ویژگیهای سطح برنامه جدا شده با حداقل خطر برای سایر برنامهها، سیستم یا کاربر را میدهد. سیستم به طور خودکار این نوع مجوز را به برنامه درخواست کننده در هنگام نصب، بدون درخواست تأیید صریح کاربر، اعطا می کند، اگرچه کاربر همیشه این گزینه را دارد که قبل از نصب، این مجوزها را بررسی کند. "dangerous"
مجوزی با ریسک بالاتر که به برنامه درخواست کننده امکان دسترسی به داده های کاربر خصوصی یا کنترل دستگاه را می دهد که می تواند تأثیر منفی بر کاربر بگذارد. از آنجا که این نوع مجوز خطر بالقوه را معرفی می کند، ممکن است سیستم به طور خودکار آن را به برنامه درخواست کننده اعطا نکند. به عنوان مثال، هر گونه مجوز خطرناک درخواست شده توسط یک برنامه ممکن است به کاربر نمایش داده شود و قبل از ادامه به تأیید نیاز داشته باشد، یا ممکن است روش دیگری برای جلوگیری از اعطای خودکار استفاده از چنین امکاناتی توسط کاربر اتخاذ شود. "signature"
مجوزی که سیستم تنها در صورتی اعطا میکند که برنامه درخواستکننده با همان گواهینامه برنامهای که مجوز را اعلام کرده امضا شده باشد. اگر گواهی ها مطابقت داشته باشند، سیستم به طور خودکار بدون اطلاع کاربر یا درخواست تأیید صریح کاربر مجوز را می دهد. "knownSigner"
مجوزی که سیستم تنها در صورتی اعطا می کند که برنامه درخواست کننده با گواهی مجاز امضا شده باشد. اگر گواهی درخواست کننده در لیست باشد، سیستم به طور خودکار بدون اطلاع کاربر یا درخواست تأیید صریح کاربر مجوز را اعطا می کند. "signatureOrSystem"
مترادف قدیمی برای
"signature|privileged"
. در سطح 23 API منسوخ شده است.مجوزی که سیستم فقط به برنامههایی اعطا میکند که در یک پوشه اختصاصی در تصویر سیستم Android هستند یا با گواهینامه مشابه برنامهای که مجوز را اعلام کرده امضا شدهاند. از استفاده از این گزینه خودداری کنید، زیرا سطح حفاظتی
"signature"
برای اکثر نیازها کافی است و بدون توجه به محل نصب برنامه ها کار می کند.مجوز
"signatureOrSystem"
برای موقعیتهای خاص خاصی استفاده میشود که در آن چندین فروشنده برنامههای کاربردی را در یک تصویر سیستم دارند و نیاز دارند ویژگیهای خاصی را به طور صریح به اشتراک بگذارند، زیرا آنها با هم ساخته میشوند.
-
- معرفی شده در:
- API سطح 1
- همچنین ببینید:
-
<uses-permission>
<permission-tree>
<permission-group>
<مجوز>
محتوا و نمونه کدها در این صفحه مشمول پروانههای توصیفشده در پروانه محتوا هستند. جاوا و OpenJDK علامتهای تجاری یا علامتهای تجاری ثبتشده Oracle و/یا وابستههای آن هستند.
تاریخ آخرین بهروزرسانی 2025-07-29 بهوقت ساعت هماهنگ جهانی.
[[["درک آسان","easyToUnderstand","thumb-up"],["مشکلم را برطرف کرد","solvedMyProblem","thumb-up"],["غیره","otherUp","thumb-up"]],[["اطلاعاتی که نیاز دارم وجود ندارد","missingTheInformationINeed","thumb-down"],["بیشازحد پیچیده/ مراحل بسیار زیاد","tooComplicatedTooManySteps","thumb-down"],["قدیمی","outOfDate","thumb-down"],["مشکل ترجمه","translationIssue","thumb-down"],["مشکل کد / نمونهها","samplesCodeIssue","thumb-down"],["غیره","otherDown","thumb-down"]],["تاریخ آخرین بهروزرسانی 2025-07-29 بهوقت ساعت هماهنگ جهانی."],[],[],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)"]]