android-permissions-device-apislisted
Install: claude install-skill lenorebreakneck630/claude-zero-to-hero-android-KMP
# Android Permissions and Device APIs
## Core Principles
- Request a permission only when the user is about to use the related feature.
- Explain value before requesting when the need is not obvious.
- Model capability state in the `ViewModel`; keep platform request launching in the UI layer.
- Handle denial, permanent denial, and unavailable capability as first-class states.
- Prefer high-level platform contracts over manual intent/result plumbing.
---
## Permission Request Philosophy
Do not ask for permissions on app launch unless the entire app is unusable without them.
Good timing:
- camera permission when tapping scan or capture
- location permission when starting nearby search or map centering
- notification permission when enabling alerts
Bad timing:
- first frame of app startup
- before the user understands the feature value
- requesting unrelated permissions in bulk
---
## Capability-Based UI State
Represent device access as UI state, not scattered boolean checks:
```kotlin
data class CameraAccessState(
val isGranted: Boolean = false,
val shouldShowRationale: Boolean = false,
val isPermanentlyDenied: Boolean = false
)
```
The screen renders from state and emits actions like `OnGrantCameraClick` or `OnOpenSettingsClick`.
---
## Compose Boundary
In Compose, launch permission or activity result contracts at the Root level and forward results as actions:
```kotlin
@Composable
fun CameraRoot(
viewModel: CameraViewModel = koinViewModel()
) {