Created
March 9, 2018 10:30
-
-
Save kanta1311/5d4acfe01d4a2852d359d7a19ec8a9b9 to your computer and use it in GitHub Desktop.
Camera Permission Android
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
if (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) { | |
takePictureButton.setEnabled(false); | |
ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE }, 0); | |
} | |
@Override | |
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { | |
if (requestCode == 0) { | |
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED | |
&& grantResults[1] == PackageManager.PERMISSION_GRANTED) { | |
takePictureButton.setEnabled(true); | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment