Skip to content

Instantly share code, notes, and snippets.

@cdmunoz
Created July 27, 2020 02:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cdmunoz/5b6a515a06d25f96dc4512bb008c7284 to your computer and use it in GitHub Desktop.
Save cdmunoz/5b6a515a06d25f96dc4512bb008c7284 to your computer and use it in GitHub Desktop.
private val cameraPermission =
registerForActivityResult(ActivityResultContracts.RequestPermission()) { granted ->
with(binding.root) {
when {
granted -> snackBar("Permission granted!")
shouldShowRequestPermissionRationale(Manifest.permission.CAMERA) -> {
//this option is available starting in API 23
snackBar("Permission denied, show more info!")
}
else -> snackBar("Permission denied")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment