Skip to content

Instantly share code, notes, and snippets.

@shikto1
Created July 4, 2018 05:40
Show Gist options
  • Save shikto1/354288d80600c6829ec3a8ca5375b7cf to your computer and use it in GitHub Desktop.
Save shikto1/354288d80600c6829ec3a8ca5375b7cf to your computer and use it in GitHub Desktop.
if (ContextCompat.checkSelfPermission(thisActivity,Manifest.permission.READ_CONTACTS)!= PackageManager.PERMISSION_GRANTED) {
if (ActivityCompat.shouldShowRequestPermissionRationale(thisActivity,
Manifest.permission.READ_CONTACTS)) {
// Show an expanation to the user
} else {
if(isFirstTimeAsking(thisActivity, Manifest.permission.READ_CONTACTS){
firstTimeAsking(thisActivity,Manifest.permission.READ_CONTACTS, false);
ActivityCompat.requestPermissions(thisActivity,new String[]{Manifest.permission.CAMERA}, REQUEST_CAMERA);
} else {
//Permission disable by device policy or user denied permanently. Show proper error message
}
}
} else {
//permission granted. do your stuff
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment