A common tool for Android Permission,support above Android SDK 23 (Android 6.0)
support Phone xiaomi.
#How to use
private String[] permissions = {
Manifest.permission.READ_CONTACTS
, Manifest.permission.SEND_SMS};
PermissionAssistant.requestPermissions(MainActivity.this, permissions, isForceGrantAllPermissions);
//or
PermissionAssistant.requestPermissions(MainActivity.this, Manifest.permission.READ_CONTACTS, isForceGrantAllPermissions);
implements PermissionAssistant.PermissionCallback
//add this to in Activity onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults);
PermissionAssistant.onRequestPermissionResult(permissions, grantResults, this);
@Override
public void onAllow(String[] permissions) {
for (int i = 0; i < permissions.length; i++) {
Log.e("allow", permissions[i]);
}
}
@Override
public void onDeny(String[] permissions) {
for (int i = 0; i < permissions.length; i++) {
Log.e("deny", permissions[i]);
}
}
//if is not grant all permissions
if (!PermissionAssistant.isGrantedAllPermissions(context)) {
PermissionAssistant.requestPermissions(context);
} else {
Log.e("PermissionAssistant", "is Granted All Permissions");
}