skip to content

Manifest and Permissions

What AndroidManifest.xml declares, protection levels, and the runtime permission request with its rationale and denial paths. Asked because a permission is a user-facing flow, not a line in a file.

on this pageshow

explore

questions

6

In Android's AndroidManifest.xml, what do the normal, signature and dangerous protection levels mean for how a declared permission is granted?

level: juniorimportance: must knowfreq 74%

answer

  1. declare first, grant second
  2. install-time vs runtime
  3. same signing certificate
  4. groups shape the dialog only

basics

~20 s

Every 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 s

An 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

for a junior

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.

for a middle

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.

for a senior

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.

for a principal

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.

open as a page

On Android, how do you request the camera permission with the RequestPermission contract, including the rationale and the denial paths?

level: middleimportance: must knowfreq 82%

basics

~10 s

Declare CAMERA, check it with ContextCompat.checkSelfPermission, show your own explanation when shouldShowRequestPermissionRationale returns true, then launch a RequestPermission launcher and handle its boolean. A denial degrades the feature; denying twice stops the dialog appearing.

open as a page

On Android, how should a nearby-posts feature declare and request location permissions, and what must it handle when the user grants only approximate location?

level: middleimportance: should knowfreq 60%

basics

~20 s

Declare ACCESS_COARSE_LOCATION, and ACCESS_FINE_LOCATION only if precision truly helps, then request them together at the moment the feature opens. If the user grants approximate only, the app gets approximate locations whatever it declared, so the feature must work on them.

open as a page

How do you guard a content provider shared with your own companion app using a custom Android permission, and why choose the signature protection level?

level: seniorimportance: should knowfreq 35%

basics

~20 s

Define a <permission> with protectionLevel signature in the app that owns the provider, name it in the provider's readPermission or permission attribute, and declare it with <uses-permission> in the companion. Signature grants it silently, only to apps signed with your certificate.

open as a page

After adding an SDK, your Android release's merged manifest declares READ_PHONE_STATE that your code never uses; how do you find its source and remove it?

level: seniorimportance: should knowfreq 45%

basics

~20 s

The build merges library manifests into yours, so check the Merged Manifest view or the manifest-merger report to see which library contributed READ_PHONE_STATE. Then add a <uses-permission> for it with tools:node="remove" to the app manifest, and test the SDK without it.

open as a page

As the lead of an Android social app, what permission policy do you set, and when do you replace a runtime permission with a permissionless system API?

level: principalimportance: should knowfreq 40%

basics

~20 s

Declare the fewest permissions each feature needs: the photo picker instead of media access, the system camera intent instead of CAMERA, coarse over precise location. Ask in context, degrade on denial, review what SDKs add and give back unused grants.

open as a page