Bird
Raised Fist0
Android Kotlinmobile~20 mins

Why runtime permissions protect user privacy in Android Kotlin - Challenge Your Understanding

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Runtime Permissions Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Why do Android apps request permissions at runtime?
Which reason best explains why Android apps ask for permissions while the app is running instead of only at install time?
ATo let users decide when to allow access to sensitive data or features, improving privacy control.
BTo make the app load faster by delaying permission checks until needed.
CTo reduce the app size by downloading permissions separately.
DBecause Android does not support permissions declared in the app manifest anymore.
Attempts:
2 left
💡 Hint
Think about how users can control what data apps can access.
❓ ui_behavior
intermediate
2:00remaining
What happens if a user denies a runtime permission?
When an Android app requests a runtime permission and the user denies it, what is the typical app behavior?
AThe app automatically requests the permission again until the user accepts.
BThe app crashes immediately because it cannot access the denied feature.
CThe app continues without the feature that needs the permission, possibly showing a message explaining the limitation.
DThe app disables all functionality and closes.
Attempts:
2 left
💡 Hint
Consider how apps handle missing permissions gracefully.
❓ lifecycle
advanced
2:00remaining
When should an app request runtime permissions?
At which point in the app lifecycle is it best practice to request a runtime permission?
AImmediately when the app starts, before showing any UI.
BRight before the app needs to use the feature that requires the permission.
COnly after the user has used the app for more than 5 minutes.
DAfter the app has crashed once due to missing permission.
Attempts:
2 left
💡 Hint
Think about when the user expects to grant access.
🔧 Debug
advanced
2:00remaining
Identify the cause of a permission denial crash
This Kotlin code snippet crashes when accessing the camera. What is the cause?
Android Kotlin
if (checkSelfPermission(Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED) {
  startCamera()
} else {
  startCamera()
}
AThe app calls startCamera() even when permission is not granted, causing a crash.
BThe permission check uses the wrong constant for CAMERA permission.
CThe app should request permission inside the else block before starting the camera.
DThe app needs to check permission in onCreate(), not here.
Attempts:
2 left
💡 Hint
Look at what happens when permission is denied.
❓ navigation
expert
3:00remaining
How to handle permission denial with 'Don't ask again' selected?
If a user denies a runtime permission and selects 'Don't ask again', what is the best way for the app to let the user enable the permission later?
AKeep requesting the permission every time the app starts until the user accepts.
BDisable the app permanently without informing the user.
CRestart the app automatically to reset permission requests.
DShow a dialog explaining the permission is needed and provide a button to open the app settings screen.
Attempts:
2 left
💡 Hint
Think about how users can manually change permissions after blocking requests.

Practice

(1/5)
1. Why do Android apps request runtime permissions instead of asking for all permissions at install time?
easy
A. To protect user privacy by asking only when the permission is needed
B. To make the app install faster
C. To reduce the app size
D. To avoid asking the user any questions

Solution

  1. Step 1: Understand runtime permissions purpose

    Runtime permissions ask users only when a feature needs access, protecting privacy.
  2. Step 2: Compare with install-time permissions

    Install-time permissions ask all at once, which can overwhelm users and reduce control.
  3. Final Answer:

    To protect user privacy by asking only when the permission is needed -> Option A
  4. Quick Check:

    Runtime permissions = protect privacy [OK]
Hint: Runtime permissions ask only when needed, protecting privacy [OK]
Common Mistakes:
  • Thinking runtime permissions speed up installation
  • Believing runtime permissions reduce app size
  • Assuming runtime permissions avoid user prompts
2. Which Kotlin code snippet correctly checks if the app has permission to access the camera before requesting it?
easy
A. if (checkPermission(Manifest.permission.CAMERA)) { /* permission granted */ }
B. if (hasPermission(Manifest.permission.CAMERA)) { /* permission granted */ }
C. if (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED) { /* permission granted */ }
D. if (requestPermission(Manifest.permission.CAMERA)) { /* permission granted */ }

Solution

  1. Step 1: Identify correct permission check method

    ContextCompat.checkSelfPermission returns permission status in Android Kotlin.
  2. Step 2: Verify correct comparison

    Compare result to PackageManager.PERMISSION_GRANTED to confirm permission granted.
  3. Final Answer:

    if (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED) { /* permission granted */ } -> Option C
  4. Quick Check:

    Use ContextCompat.checkSelfPermission == PERMISSION_GRANTED [OK]
Hint: Use ContextCompat.checkSelfPermission with PERMISSION_GRANTED check [OK]
Common Mistakes:
  • Using non-existent methods like checkPermission or hasPermission
  • Calling requestPermission instead of checking permission
  • Not comparing to PERMISSION_GRANTED constant
3. Given this Kotlin code snippet, what will be the output if the user denies the permission request?
if (ContextCompat.checkSelfPermission(this, Manifest.permission.LOCATION) != PackageManager.PERMISSION_GRANTED) {
  ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.LOCATION), 100)
} else {
  println("Permission already granted")
}
medium
A. Nothing printed immediately; permission request dialog shown
B. Permission already granted
C. App crashes due to missing permission
D. Permission denied message printed

Solution

  1. Step 1: Analyze permission check condition

    Permission is not granted, so requestPermissions is called to ask user.
  2. Step 2: Understand immediate output

    requestPermissions shows dialog asynchronously; no immediate print happens.
  3. Final Answer:

    Nothing printed immediately; permission request dialog shown -> Option A
  4. Quick Check:

    Permission request dialog shows, no immediate print [OK]
Hint: requestPermissions shows dialog, no immediate output printed [OK]
Common Mistakes:
  • Assuming println runs before user responds
  • Expecting crash without handling permission denial
  • Thinking denial message prints automatically
4. What is wrong with this Kotlin code snippet for requesting permission?
ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.READ_CONTACTS), 1)
if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_CONTACTS) == PackageManager.PERMISSION_GRANTED) {
  println("Permission granted")
}
medium
A. println statement should be outside the if block
B. Permission check is done immediately after request, before user responds
C. Manifest.permission.READ_CONTACTS is not a valid permission
D. requestPermissions method is called with wrong parameters

Solution

  1. Step 1: Understand requestPermissions behavior

    requestPermissions shows dialog asynchronously; user response is not immediate.
  2. Step 2: Identify timing of permission check

    Checking permission immediately after request will not reflect user's choice yet.
  3. Final Answer:

    Permission check is done immediately after request, before user responds -> Option B
  4. Quick Check:

    Check permission after user response, not immediately [OK]
Hint: Check permission after user responds, not right after request [OK]
Common Mistakes:
  • Checking permission immediately after requestPermissions call
  • Assuming requestPermissions blocks until user answers
  • Misusing permission constants
5. An app needs to access the user's location only when showing nearby stores. How should it use runtime permissions to protect user privacy best?
hard
A. Request all permissions including location at install time
B. Request location permission immediately when the app starts
C. Never request location permission and guess location from IP
D. Request location permission only when the user tries to view nearby stores

Solution

  1. Step 1: Identify when location is needed

    Location is needed only when user views nearby stores, not before.
  2. Step 2: Apply runtime permission best practice

    Request permission only at the moment feature is used to respect privacy and reduce prompts.
  3. Final Answer:

    Request location permission only when the user tries to view nearby stores -> Option D
  4. Quick Check:

    Request permission when feature used, protect privacy [OK]
Hint: Ask permission only when feature needs it, not before [OK]
Common Mistakes:
  • Requesting permission too early at app start
  • Requesting all permissions upfront at install
  • Avoiding permission request and guessing location
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard