Skip to content

Instantly share code, notes, and snippets.

@shikto1
Last active July 3, 2018 04:34
Show Gist options
  • Save shikto1/cff61403f092d13cb7349d5786805174 to your computer and use it in GitHub Desktop.
Save shikto1/cff61403f092d13cb7349d5786805174 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