Created
May 11, 2020 20:47
-
-
Save LiorA1/7552c136bc29c6f0fd6a84804f60c5f9 to your computer and use it in GitHub Desktop.
isPermissionGranted basic example
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
public boolean isPermissionGranted() | |
{ | |
boolean res = false; | |
if (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED | |
&& ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED | |
&& ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED | |
/*&& ContextCompat.checkSelfPermission(this, Manifest.permission.RECORD_AUDIO) == PackageManager.PERMISSION_GRANTED*/) | |
{ | |
res = true; | |
} | |
// Else ask for permission | |
else | |
{ | |
ActivityCompat.requestPermissions(this, | |
new String[]{ | |
Manifest.permission.CAMERA, | |
Manifest.permission.WRITE_EXTERNAL_STORAGE, | |
Manifest.permission.READ_EXTERNAL_STORAGE, | |
/*Manifest.permission.RECORD_AUDIO*/}, | |
0); | |
} | |
return res; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment