Android jumps to specific application permission management, three ways

16030803:

Background: Android is becoming more and more secure and compliant. In the application, it is necessary to give users all the clear ways to choose and cancel.

For example: if the permission is set, the user should also be given the access to close the permission. It is required to provide permission management entry in the application settings.

There are three solutions:

Method 1: Make custom adaptations for each mobile phone manufacturer

A bit laborious, but precise, as follows:

//小米手机-跳转本应用权限
LogUtils.INSTANCE.d("jumpSettings 小米应用权限");
try {
Intent intent = new Intent("miui.intent.action.APP_PERM_EDITOR");
intent.putExtra("extra_pkgname", context.getPackageName());
ComponentName componentName = new ComponentName("com.miui.securitycenter", "com.miui.permcenter.permissions.PermissionsEditorActivity");
intent.setComponent(componentName);
context.startActivity(intent);
} catch (Exception e) {
LogUtils.INSTANCE.d("jumpSettings 小米应用权限 Exception:"+e.getMessage());
e.printStackTrace();

}

 

//华为手机手机-跳转本应用权限
try {
Intent intent = new Intent();
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra("packageName", context.getApplicationInfo().packageName);
ComponentName comp = new ComponentName("com.huawei.systemmanager", "com.huawei.permissionmanager.ui.MainActivity");
intent.setComponent(comp);
context.startActivity(intent);
} catch (Exception e) {
e.printStackTrace();
}

Refer to  Summary of Android Jump Authority Management Interface_Android Jump Authority Management_Xiaohongmei's Blog-CSDN Blog

Method 2: Jump to the application details and directly open the application permission settings

Advantages: the method is available on general mobile phone manufacturers

//跳转应用消息,间接打开应用权限设置-效率高
Intent intent = new Intent();
intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
Uri uri = Uri.fromParts("package", context.getPackageName(), null);
intent.setData(uri);
context.startActivity(intent);

Method 3: Guide the user to enter the system setting page

Just give him a general direction, and focus on a guide

//引导用户只系统设置页面,更加间接开启设置应用
context.startActivity(new Intent(android.provider.Settings.ACTION_SETTINGS));

Create value, happy to share!

Guess you like

Origin blog.csdn.net/ly_xiamu/article/details/131310480