Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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