Hello all. I am looking for help on how to determ...
# compose
b
Hello all. I am looking for help on how to determine if a permission dialog has been shown to the user. I would like to remain in my current composable until the user either rejects the permission, allows the permission, or dismisses the permission dialog. Code in reply.
Using Accompanist:
Copy code
val locationPermissionState = rememberMultiplePermissionsState(
   listOf(
      android.Manifest.permission.ACCESS_FINE_LOCATION,
      android.Manifest.permission.ACCESS_COARSE_LOCATION
   )
)
Copy code
Button(
   onClick = {
      locationPermissionState.launchMultiplePermissionRequest()
   }
) {
   Text(text = "Enable Location")
}
I can determine if a user has accepted any permission by looking at locationPermissionState.permissions. However I cannot detect if the user taps outside the permission dialog to dismiss it. I am showing this at initial app launch and don’t really care if the user accepts or rejects the permission, I would just like to give them an opportunity and move on.
c
This might not be the answer you’re looking for but generally you want to ask for permission at the screen where you need it. Besides being better UX it makes it easy to show placeholder content in the event that the user hasn’t yet (or doesn’t) grant permission. This way you can show the user the rationale for your request. And, if they’ve previously denied your request and you’re no longer able to launch a permission request, you can give them directions on how to update their permission settings
b
Seems like a pretty common use case, I see many apps that have a wizard or walkthrough of the application to let users know what you are doing with the notifications. This screenshot is pulled from androids docs on notifications here: https://developer.android.com/develop/ui/views/notifications/notification-permission#exemptions Just trying to mimic that example. I did figure out another way around. Thanks
c
Ah ok I see what you mean now, yeah I agree that kind of wizard at the start is useful. I don’t know what happens if the user dismisses the permission dialog without granting or denying the permission. I’d have to test it out to see the behaviour (if any)