- 構文:
<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
属性など)で使用される名前。注: すべてのパッケージが同じ証明書を使用して署名されている場合を除き、複数のパッケージで同じ名前の権限を宣言することはできません。パッケージで権限を宣言すると、ユーザーは同じ権限名の他のパッケージをインストールできなくなります(他のパッケージが最初のパッケージと同じ証明書を使用して署名されている場合を除く)。
このため、Google では、逆ドメイン形式の命名方法を使用して、権限の前にアプリのパッケージ名を接頭辞として付加することをおすすめします。この接頭辞の後に
.permission.
を付加し、その後に権限が表す機能の説明を大文字の SNAKE_CASE 形式で指定します(例:com.example.myapp.permission.ENGAGE_HYPERSPACE
)。このおすすめの方法を採用すると、名前の競合を回避し、カスタム権限の所有者と意図を明確に示すことができます。
android:permissionGroup
- この権限を割り当てるグループ。この属性の値はグループ名です。グループ名は、このアプリまたは別のアプリで
<permission-group>
要素を使用して宣言します。この属性が設定されていない場合、権限はグループに属しません。 android:protectionLevel
-
権限に含まれている可能性があるリスクと、権限をリクエスト元のアプリに付与するかどうかを決める際にシステムが従う手順を指定します。
各保護レベルは、基本権限タイプと 0 個以上のフラグで構成されます。たとえば、
"dangerous"
保護レベルにはフラグがありません。一方、"signature|privileged"
保護レベルは"signature"
基本権限タイプと"privileged"
フラグを組み合わせたものです。次の表で、すべての基本権限タイプについて説明します。フラグの一覧については、
protectionLevel
をご覧ください。値 意味 "normal"
デフォルト値。分離されたアプリレベルの機能へのアクセスをリクエスト元のアプリに提供する低リスクの権限。他のアプリ、システム、ユーザーに対するリスクを最小限に抑えることができます。システムはリクエスト元のアプリに対し、このタイプの権限をインストール時に自動的に付与します。ユーザーによる明示的な承認を求めることはありません。ただし、ユーザーはインストール前にいつでもこれらの権限を確認できます。 "dangerous"
リクエスト元のアプリによる個人データへのアクセスあるいはデバイスの管理を許し、ユーザーに悪影響を及ぼす高リスクの権限。このタイプの権限はリスクが高いため、システムがリクエスト元のアプリに自動的に権限を付与することはありません。たとえば、アプリからリクエストされた危険な権限がユーザーに表示され、先に進む前に確認が必要になることがあります。このような機能の使用にユーザーが知らずに同意することを防ぐため、他のなんらかのアプローチがとられる場合もあります。 "signature"
権限を宣言したアプリと同じ証明書がリクエスト元のアプリの署名に使用されている場合にのみシステムから付与される権限。証明書が一致した場合、システムが自動的に権限を付与します。ユーザーに通知したり、ユーザーによる明示的な承認を求めたりすることはありません。 "knownSigner"
許可された証明書がリクエスト元のアプリの署名に使用されている場合にのみシステムから付与される権限。リクエスト元の証明書が記載されている場合は、ユーザーに通知したり、ユーザーの明示的な承認を求めたりすることなく、システムが自動的に権限を付与します。 "signatureOrSystem"
"signature|privileged"
の以前の同義語。API レベル 23 で非推奨になりました。Android システム イメージの専用フォルダにインストールされているアプリ、または権限を宣言したアプリと同じ証明書を使用して署名されたアプリにのみシステムから付与される権限。
"signature"
保護レベルはほとんどのニーズを満たし、アプリのインストール場所を問わず機能するため、このオプションは使用しないでください。"signatureOrSystem"
権限は、複数のベンダーがアプリをシステム イメージに組み込んでおり、特定の機能がまとめてビルドされているという理由でそれらを明示的に共有する必要がある特殊な状況で使用されます。
- 導入時の API レベル:
- API レベル 1
- 関連項目:
<uses-permission>
<permission-tree>
<permission-group>
<permission>
このページのコンテンツやコードサンプルは、コンテンツ ライセンスに記載のライセンスに従います。Java および OpenJDK は Oracle および関連会社の商標または登録商標です。
最終更新日 2025-07-27 UTC。
[null,null,["最終更新日 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)"]]