Runtime permissions

Lifecycle and app components Junior Kotlin 2.0+ API 33+ Reviewed By Best Latest Apps

Order the steps

Order the steps to request the camera permission well.

  • If shouldShowRequestPermissionRationale is true, explain why
  • If denied permanently, offer a Settings link
  • Check checkSelfPermission; if granted, open the camera
  • User taps 'Scan receipt'
  • Launch the permission request

Choose an answer, then open Show answer below to check it.

Show answer

Answer: D C A E B

  1. User taps 'Scan receipt' Ask in context, when the feature is used.
  2. Check checkSelfPermission; if granted, open the camera No dialog if you already have it.
  3. If shouldShowRequestPermissionRationale is true, explain why Users who denied once get a reason.
  4. Launch the permission request The system dialog appears.
  5. If denied permanently, offer a Settings link The system won't show the dialog again.

30-second answer

Ask at the moment the user tries the feature, not at launch. Check with ContextCompat.checkSelfPermission; if denied, show a short explanation when shouldShowRequestPermissionRationale is true, then request with the Activity Result API. If the user denies twice, the system stops showing the dialog, so offer a link to the app's settings instead.

Practise saying it · 35 s. No recording, just a timer

Explain how to request permissions well.

Say your answer out loud, then check which of these points you covered:

  • Ask in context
  • Explain with rationale
  • Request with the Activity Result API
  • Handle permanent denial
  • Prefer permission-free alternatives

Deep dive

POST_NOTIFICATIONS is a runtime permission since Android 13.

Location has foreground and background levels; ask for foreground first, and background separately with a clear reason.

Android 14 lets users grant partial access to photos and videos (READ_MEDIA_VISUAL_USER_SELECTED); handle that state.

Prefer permission-free options: the photo picker, ACTION_DIAL instead of CALL_PHONE, approximate location if precise isn't needed.

Requesting notification permission in Compose Compile-checked · Kotlin 2.4.21
@Composable
fun EnableAlertsButton(onGranted: () -> Unit) {
    val launcher = rememberLauncherForActivityResult(ActivityResultContracts.RequestPermission()) { granted ->
        if (granted) onGranted()
    }
    Button(onClick = { launcher.launch(Manifest.permission.POST_NOTIFICATIONS) }) {
        Text("Turn on alerts")
    }
}

Common mistakes

  • Asking for every permission at first launch.
  • Re-requesting forever after a permanent denial.
  • Asking for storage permissions to pick a single image.

Senior take & follow-ups

Talk about timing and alternatives that avoid the permission entirely; Play reviewers care about both.

Follow-up questions

Think of your answer first, then open the hint.

  1. What happens after two denials?

    Show hint

    The request returns denied without a dialog; send the user to settings.

  2. How do you handle partial photo access?

    Show hint

    Treat selected-photos access as granted for those items and offer to pick more.

Suggest a fix if something here is wrong or out of date.