private void checkPerms() {
String[] perms = new String[]{
Manifest.permission.READ_PHONE_STATE,
Manifest.permission.RECORD_AUDIO,
Manifest.permission.READ_CONTACTS,
Manifest.permission.PROCESS_OUTGOING_CALLS };
List<String> requestingPerms = new ArrayList<>();
for (String perm : perms) {
if (checkSelfPermission(perm) !=
PackageManager.PERMISSION_GRANTED) {
requestingPerms.add(perm);
}
}
if (requestingPerms.size() > 0) {
requestPermissions(requestingPerms.toArray(new String[requestingPerms.size()]), 0);
}
}
check permission:
PackageManager pm = getPackageManager();
int hasPerm = pm.checkPermission(Manifest.permission.CAMERA, getPackageName());
if (hasPerm == PackageManager.PERMISSION_GRANTED) {
selectFile();
}else{
checkPerms()
}