Created
August 18, 2019 08:53
-
-
Save akshaymukadam/df2d06356ac24cb9c2bd1856e2b2f79a to your computer and use it in GitHub Desktop.
Permission Check request permission
This file contains hidden or 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
if (ContextCompat.checkSelfPermission(this, $PERMISSION$) | |
!= PackageManager.PERMISSION_GRANTED) { | |
// Permission is not granted | |
// Should we show an explanation? | |
if (ActivityCompat.shouldShowRequestPermissionRationale(this, | |
$PERMISSION$)) { | |
TODO("Show Explainantion if needed") | |
} else { | |
// No explanation needed, we can request the permission. | |
ActivityCompat.requestPermissions(this, | |
arrayOf($PERMISSION$), | |
$REQUESTCODE$) | |
} | |
} else { | |
// Permission has already been granted | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment