Skip to content

Instantly share code, notes, and snippets.

@ssaurel
Created October 19, 2017 12:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ssaurel/590dcc4e81d1acfccd39f96d8f795913 to your computer and use it in GitHub Desktop.
Save ssaurel/590dcc4e81d1acfccd39f96d8f795913 to your computer and use it in GitHub Desktop.
Request Permission Camera on the SSaurel's Blog
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
switch(requestCode) {
case CAMERA_REQUEST :
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
buttonEnable.setEnabled(false);
buttonEnable.setText("Camera Enabled");
imageFlashlight.setEnabled(true);
} else {
Toast.makeText(MainActivity.this, "Permission Denied for the Camera",
Toast.LENGTH_SHORT).show();
}
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment