The new registerForActivityResult method makes it very simple to ask for permission, as follows:
registerForActivityResult(ActivityResultContracts.RequestPermission()) { granted ->
when {
granted -> getUserLocation()
else -> {
//permission denied
}
}
}
However, how can I detect that the user has denied permission with the "never ask again" checkbox or in Android 11+ has denied permission permanently? In these scenarios, I want to redirect the user to the device's Settings screen?