← ClaudeAtlas

android-permissions-device-apislisted

Runtime permissions and device API patterns for Android - permission requests, rationale flows, activity results, camera, location, notifications, and capability-based feature access. Use this skill whenever adding access to device capabilities or platform services that require runtime permission or launcher-based contracts. Trigger on phrases like "permission", "camera", "location", "notifications", "activity result", "pick image", "request permission", or "device capability".
lenorebreakneck630/claude-zero-to-hero-android-KMP · ★ 1 · API & Backend · score 64
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() ) {