https://kotlinlang.org logo
#compose
Title
# compose
m

Mehdi Haghgoo

10/20/2021, 11:39 AM
I don't find anything in Compose docs regarding how to request Android permissions? ...
d

Damian Zawadzki

10/20/2021, 11:44 AM
i

Ian Lake

10/20/2021, 1:05 PM
m

Mehdi Haghgoo

10/20/2021, 1:08 PM
Yes, it's there in the documentation. Thanks
Strangely, though, the following code does not work:
val recordAudioPerm = rememberPermissionState(android.Manifest.permission.RECORD_AUDIO)
Button(onClick={
if (! recordAudioPerm.hasPermission) {recordAudioPerm.launchPermissionRequest()}
}
){
Text("Record")
}
I mean, the permission prompt is never shown, and debugging shows that the value of recordAudioPerm is true!
Turns out I was running the code on an Android 5.0 device!
Runtime permissions work only with Android M+.
i

Ian Lake

10/20/2021, 5:32 PM
ha, yeah that'll do it
❤️ 1