Skip to content

Instantly share code, notes, and snippets.

@shishirthedev
Created January 23, 2019 18:42
Show Gist options
  • Select an option

  • Save shishirthedev/3e8ee30865eae92972e4817ad50b923b to your computer and use it in GitHub Desktop.

Select an option

Save shishirthedev/3e8ee30865eae92972e4817ad50b923b to your computer and use it in GitHub Desktop.
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
switch (requestCode) {
case REQUEST_CAMERA: {
// If request is cancelled, the result arrays are empty.
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
//Permission was granted. Now you can call your method to open camera, fetch contact or whatever
openCamera();
} else {
// Permission was denied.......
// You can again ask for permission from here
Toast.makeText(this, "Permission Denied", Toast.LENGTH_SHORT).show();
}
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment