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
// Here, thisActivity is the current activity | |
if (ContextCompat.checkSelfPermission(thisActivity, | |
Manifest.permission.READ_CONTACTS) | |
!= PackageManager.PERMISSION_GRANTED) { | |
// Should we show an explanation? | |
if (ActivityCompat.shouldShowRequestPermissionRationale(thisActivity, | |
Manifest.permission.READ_CONTACTS)) { | |
// Show an expanation to the user *asynchronously* -- don't block | |
// this thread waiting for the user's response! After the user | |
// sees the explanation, try again to request the permission. |
NewerOlder