CAMERA is a runtime permission. Declare it, and mark the hardware optional so Google Play 1 still offers the app to devices without a camera:
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" android:required="false" />The camera screen asks as it opens, since its purpose is obvious, and explains itself if refused:
val ask = rememberLauncherForActivityResult(ActivityResultContracts.RequestPermission()) {
granted = it
}
LaunchedEffect(Unit) { if (!granted) ask.launch(Manifest.permission.CAMERA) }
if (!granted) {
Text("BookNest needs the camera to photograph a book you want to sell.", modifier)
return
}The dialog (figure in Capturing Photos) also offers a one-time grant that lapses soon after the app leaves the foreground, so check on every visit. For a single photo without the permission, launch the system camera with ActivityResultContracts.TakePicture().