In Android's AndroidManifest.xml, what do the normal, signature and dangerous protection levels mean for how a declared permission is granted?
answer
- declare first, grant second
- install-time vs runtime
- same signing certificate
- groups shape the dialog only
basics
~20 sEvery permission an Android app uses is declared with <uses-permission>; its protection level decides the grant. Normal permissions are granted at install, signature permissions only to apps signed with the declaring certificate, and dangerous ones must also be requested at runtime.
solid answer
~50 sAn app lists every permission it needs with `<uses-permission>` in `AndroidManifest.xml`, whatever Android version it supports; the declaration alone is not a grant. The permission's `protectionLevel` decides what happens next. A `normal` permission is low-risk and the system grants it at install time. A `signature` permission is granted silently, but only when the requesting app is signed with the same certificate as the app or OS that defined it. A `dangerous` permission (a runtime permission) guards private data such as location or the camera: on Android 6.0 (API 23) and higher the app must also ask the user at runtime, and must check it before each use because the user can revoke it. A fourth kind, special permissions with the `appop` level, is toggled by the user under Special app access. Permission groups only shape the system dialog and can change without notice, so code never relies on them.
go deeper
Recall the three common levels and how each is granted: normal at install, signature by matching certificate, dangerous by asking the user at runtime, after declaring all of them in the manifest.
Explain why a declared dangerous permission still needs a runtime check before every use: revocation, one-time grants and auto-reset all change the answer while the app is installed.
Show you read a merged manifest for its protection levels: which entries cost the user a prompt, which are silent, and which grouping effects change what users actually see.
Frame protection levels as a product cost: each dangerous permission is a prompt users can refuse, so a lead pushes the app toward fewer of them and signature-level sharing between first-party apps.
## Declaring is not granting `AndroidManifest.xml` is where an Android app states what it is and what it needs. A **`<uses-permission>`** element names one permission the app wants, for example `android.permission.CAMERA`. The Android documentation is explicit that you declare every permission you use this way **no matter which Android version your app supports**: without the declaration the request can never succeed and the protected API fails. But a declaration is only a claim. What the system does with it depends on the permission's **protection level**, a property set by whoever *defined* the permission (the platform, a device maker, or another app through a `<permission>` element and its `android:protectionLevel` attribute). ## The levels and how each is granted | Protection level | Also called | How it is granted | Typical use | |---|---|---|---| | `normal` | install-time | Automatically at install; an app store can list it on the details page | Access just outside the app's sandbox with very little privacy risk | | `signature` | install-time | Automatically, but only if the requester is signed with the same certificate as the app or OS that defined it | Privileged services such as autofill or VPN binding; your own app suite | | `dangerous` | runtime | Declared, then requested from the user at runtime on Android 6.0 (API 23) and higher | Private user data and sensitive hardware: location, contacts, camera, microphone | | `appop` | special | Toggled by the user on the Special app access page in system settings | Powerful operations such as drawing over other apps | A few things worth saying precisely in an interview: - **Normal** permissions are not prompted. The user can review them before installing, but there is no runtime dialog. - **Signature** permissions are not prompted either. If the certificates match, the grant is silent; if they do not, a plain signature permission is never granted, however the app asks (Android 12 added a `knownSigner` flag that lets the defining app list other trusted certificates). - **Dangerous** permissions are the ones with a user-facing flow. On a device running Android 5.1 (API 22) or lower they were granted at install; from Android 6.0 the app must call the runtime request API. - **Special** permissions can only be *defined* by the platform and device makers, and they follow their own request process rather than the runtime dialog. ## Why "dangerous" means "check every time" A runtime permission is not a one-off event. The user can revoke it in system settings at any time, a one-time grant ("Only this time", Android 11 / API 30, for location, microphone and camera) lapses soon after the app leaves the foreground, and the system can reset the runtime permissions of an app that has gone unused for a few months when that app targets Android 11 or higher. The documentation therefore says: don't assume it was granted earlier — **check before each access**, and request again if needed. When a user revokes any permission from settings, the app's process is terminated, so a long-lived "we checked at startup" flag is stale by definition. ## Permission groups Permissions belong to **permission groups** (for example the location group or the nearby-devices group). A group exists so the system can minimise the number of dialogs when an app asks for closely related permissions; the dialog text names the group, not the individual permission. Two rules follow: 1. Code must **not** assume two permissions share a group, because permissions can change groups without notice. 2. Grouping can still change what the *user sees*. Android 17 (API 37) is a live example: it adds the **`ACCESS_LOCAL_NETWORK`** runtime permission for LAN access, mandatory for apps that target API 37, inside the existing `NEARBY_DEVICES` group. Users who already granted another permission in that group are not prompted again. The app still declares the permission and still requests it; the group only changes whether a dialog appears. ## Putting it together For a social app that posts photos and shows nearby posts: - `CAMERA` and the location permissions are **dangerous**: declared, then requested in context at runtime, and checked before each use. - A custom permission the app defines to protect data it shares with its own companion app is best made **signature**, so only apps signed with the same certificate get it, silently. - Nothing about the declaration in the manifest tells you whether the user said yes. Only `ContextCompat.checkSelfPermission()` returning `PERMISSION_GRANTED` does. The short version: the manifest says *what the app may ask for*, the protection level says *who decides*, and for dangerous permissions the user decides at runtime and can change their mind later.
- What are special permissions, and how do they differ from dangerous ones?Special permissions guard particularly powerful operations, such as drawing over other apps. Only the platform and device makers can define them, and the system assigns them the `appop` protection level. They are not granted through the runtime permission dialog: the user toggles them on the Special app access page in system settings, and the app follows a separate request process to send the user there.
- On Android 17, why might a user see no prompt when your app requests ACCESS_LOCAL_NETWORK?`ACCESS_LOCAL_NETWORK` belongs to the existing `NEARBY_DEVICES` permission group, so a user who already granted another permission in that group is not prompted again. The app must still declare it and request it, since enforcement is mandatory for apps targeting API 37. The general rule stands: don't build logic on grouping, because permissions can change groups without notice.
- Declaring a dangerous permission in the manifest is enough to have it on modern Android.
- Runtime permissions don't need a <uses-permission> entry, only the runtime request.
- A signature permission shows the user a dialog before it is granted.
- Permissions in the same group are always granted together, so code can rely on grouping.
- Checking a runtime permission once at app start is enough for the whole session.
Assumes Android 17 (API 37): runtime requests exist since Android 6.0 (API 23), and API 37 makes ACCESS_LOCAL_NETWORK a required runtime permission for apps that target it.