Android 以编程方式自动启动权限
我正在开发一个应用程序,在该应用程序中,我需要向用户请求autostart权限,为此,我打开autostart权限设置页面,以便用户使用以下代码为少数制造商打开我们的应用程序的权限:Android 以编程方式自动启动权限,android,autostart,moto,oppo,Android,Autostart,Moto,Oppo,我正在开发一个应用程序,在该应用程序中,我需要向用户请求autostart权限,为此,我打开autostart权限设置页面,以便用户使用以下代码为少数制造商打开我们的应用程序的权限: Intent autostartIntent = new Intent(); if ("xiaomi".equalsIgnoreCase(android.os.Build.MANUFACTURER)) { autostartIntent.setComponent(new ComponentNa
Intent autostartIntent = new Intent();
if ("xiaomi".equalsIgnoreCase(android.os.Build.MANUFACTURER)) {
autostartIntent.setComponent(new ComponentName("com.miui.securitycenter", "com.miui.permcenter.autostart.AutoStartManagementActivity"));
startActivity(autostartIntent);
} else if ("oppo".equalsIgnoreCase(android.os.Build.MANUFACTURER)) {
autostartIntent.setComponent(new ComponentName("com.coloros.safecenter", "com.coloros.safecenter.permission.startup.StartupAppListActivity"));
startActivity(autostartIntent);
} else if ("vivo".equalsIgnoreCase(android.os.Build.MANUFACTURER)) {
autostartIntent.setComponent(new ComponentName("com.vivo.permissionmanager", "com.vivo.permissionmanager.activity.BgStartUpManagerActivity"));
startActivity(autostartIntent);
} else if ("huawei".equalsIgnoreCase(android.os.Build.MANUFACTURER)) {
autostartIntent.setComponent(new ComponentName("com.huawei.systemmanager", "com.huawei.systemmanager.optimize.process.ProtectActivity"));
startActivity(autostartIntent);
}
此外,当我尝试将用户重定向到以下设备时,我面临以下困难:
找到了这个问题的解决方案,我正在打开电池优化页面,让用户关闭我的应用程序的电池优化 以下是我正在使用的代码:
AlertDialog.Builder builder = new AlertDialog.Builder(PermissionsActivity.this);
builder.setTitle("Turn off Battery Optimization");
builder.setMessage("Find XYZ in the list of applications and choose ‘Don’t optimize’.");
builder.setPositiveButton("Allow",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
if (Build.VERSION.SDK_INT >= 23) {
Intent intent = new Intent();
intent.setAction(Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS);
startActivity(intent);
}
}
});
builder.setNegativeButton("Deny", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
finish();
}
});
builder.show();
请澄清一下:您是否使用此代码示例在华为进行了测试?我以前知道制造商的名字叫“荣誉”