Created
October 19, 2017 12:46
-
-
Save ssaurel/590dcc4e81d1acfccd39f96d8f795913 to your computer and use it in GitHub Desktop.
Request Permission Camera on the SSaurel's Blog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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