Created
March 6, 2021 16:10
-
-
Save Kashif-E/bd8f057861c465ffb805ea0fd6a9f343 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private val cameraPermission = | |
registerForActivityResult(ActivityResultContracts.RequestPermission()) { granted -> | |
with(binding.root) { | |
when { | |
granted -> { | |
showToastMessageInCenter("Permission Granted") | |
startCamera() | |
} | |
shouldShowRequestPermissionRationale(Manifest.permission.CAMERA) -> { | |
//this will be shown if the phone is running on api level > 23 else only classic dialog will be shown | |
showToastMessageInCenter("Permission Denied,Permission is needed to take photos") | |
} | |
else -> showToastMessageInCenter("Permission Denied") | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment