Skip to content

Instantly share code, notes, and snippets.

@Egorand
Created July 17, 2016 11:53
Show Gist options
  • Save Egorand/c96a161e5138baa97a32c515d2a5efa1 to your computer and use it in GitHub Desktop.
Save Egorand/c96a161e5138baa97a32c515d2a5efa1 to your computer and use it in GitHub Desktop.
android-testing-runtime-permissions-checking-permissions
@Override
protected void onResume() {
super.onResume();
int permissionStatus = ContextCompat.checkSelfPermission(this, Manifest.permission.READ_CONTACTS);
if (permissionStatus == PackageManager.PERMISSION_GRANTED) {
loadContacts();
} else if (!isPermissionAlreadyDenied) {
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_CONTACTS},
REQ_CODE_PERMISSIONS_READ_CONTACTS);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment