Created
December 30, 2020 12:34
-
-
Save Kashif-E/55b582240ed8bcf7217cfe07aed6c33c 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) | |
.withPermissions( | |
Manifest.permission.CAMERA, | |
Manifest.permission.WRITE_EXTERNAL_STORAGE | |
).withListener(object : MultiplePermissionsListener { | |
override fun onPermissionsChecked(report: MultiplePermissionsReport) { | |
report.let { | |
if (report.areAllPermissionsGranted()) { | |
Toast.makeText(this@MainActivity, "Permissions Granted", Toast.LENGTH_SHORT).show() | |
} else { | |
Toast.makeText(this@MainActivity, "Please Grant Permissions 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