getPermissionState

abstract fun getPermissionState(permission: String): StateFlow<PermissionState>

Returns StateFlow for a given permission

Parameters

permission

Unique permission identity (for e.g. android.Manifest.permission.READ_CONTACTS)

Example:

permissionFlow.getPermissionState(android.Manifest.permission.READ_CONTACTS)
.collect { state ->
if (state.isGranted) {
// Do something
} else {
if (state.isRationaleRequired) {
// Do something
}
}
}