Created
December 30, 2020 12:28
-
-
Save Kashif-E/947fdb757a5a0924e365f02f747dd820 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 fun getPermission() { | |
Dexter.withContext(this) | |
.withPermission( | |
Manifest.permission.CAMERA | |
).withListener(object : MultiplePermissionsListener { | |
override fun onPermissionsChecked(report: MultiplePermissionsReport) { | |
report.let { | |
if (report.areAllPermissionsGranted()) { | |
Toast.makeText(this@MainActivity, "Permission Granted", Toast.LENGTH_SHORT).show() | |
} else { | |
Toast.makeText(this@MainActivity, "Please Grant Permission to use the app", Toast.LENGTH_SHORT).show() | |
} | |
} | |
} | |
override fun onPermissionRationaleShouldBeShown(permissions: List<PermissionRequest?>?, token: PermissionToken?) { | |
token?.continuePermissionRequest() | |
} | |
}).withErrorListener{ | |
Toast.makeText(this, it.name, Toast.LENGTH_SHORT).show() | |
}.check() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment