问题描述
- 如何以编程方式启用自动启动权限?
- 如何查找哪个手机需要执行自动启动代码?
- 如何检查自动启动权限是启用还是禁用?
我只能找到具有canDrawOverlay()
权限的 Display popup权限.
I am able to find only about Display popup permission with canDrawOverlay()
permission`.
如果设备未启用,我想为该设备启用自动启动.
I want to enable auto-start for the device if it is not enabled.
我找到了小米,荣耀和租赁的解决方案.
I have found a solution for Xiaomi, honor and let.
if(Build.BRAND.equalsIgnoreCase("xiaomi") ){
Intent intent = new Intent();
intent.setComponent(new ComponentName("com.miui.securitycenter", "com.miui.permcenter.autostart.AutoStartManagementActivity"));
startActivity(intent);
}else if(Build.BRAND.equalsIgnoreCase("Letv")){
Intent intent = new Intent();
intent.setComponent(new ComponentName("com.letv.android.letvsafe", "com.letv.android.letvsafe.AutobootManageActivity"));
startActivity(intent);
}
else if(Build.BRAND.equalsIgnoreCase("Honor")){
Intent intent = new Intent();
intent.setComponent(new ComponentName("com.huawei.systemmanager", "com.huawei.systemmanager.optimize.process.ProtectActivity"));
startActivity(intent);
}
推荐答案
请检查以下解决方案,以为OPPO
和VIVO
设备启用floating window
和autostart permission
.
Please check the following solution to enable the floating window
and autostart permission
for OPPO
and VIVO
devices.
无法找出是否已启用自动启动"选项.您可以在Security permissions => Autostart => Enable Autostart
下手动检查.
There's no way to find out whether the Auto-start option is enabled or not. You can manually check under Security permissions => Autostart => Enable Autostart
.
private void initOPPO() {
try {
Intent i = new Intent(Intent.ACTION_MAIN);
i.setComponent(new ComponentName("com.oppo.safe", "com.oppo.safe.permission.floatwindow.FloatWindowListActivity"));
startActivity(i);
} catch (Exception e) {
e.printStackTrace();
try {
Intent intent = new Intent("action.coloros.safecenter.FloatWindowListActivity");
intent.setComponent(new ComponentName("com.coloros.safecenter", "com.coloros.safecenter.permission.floatwindow.FloatWindowListActivity"));
startActivity(intent);
} catch (Exception ee) {
ee.printStackTrace();
try{
Intent i = new Intent("com.coloros.safecenter");
i.setComponent(new ComponentName("com.coloros.safecenter", "com.coloros.safecenter.sysfloatwindow.FloatWindowListActivity"));
startActivity(i);
}catch (Exception e1){
e1.printStackTrace();
}
}
}
}
VIVO的自动启动权限
private static void autoLaunchVivo(Context context) {
try {
Intent intent = new Intent();
intent.setComponent(new ComponentName("com.iqoo.secure",
"com.iqoo.secure.ui.phoneoptimize.AddWhiteListActivity"));
context.startActivity(intent);
} catch (Exception e) {
try {
Intent intent = new Intent();
intent.setComponent(new ComponentName("com.vivo.permissionmanager",
"com.vivo.permissionmanager.activity.BgStartUpManagerActivity"));
context.startActivity(intent);
} catch (Exception ex) {
try {
Intent intent = new Intent();
intent.setClassName("com.iqoo.secure",
"com.iqoo.secure.ui.phoneoptimize.BgStartUpManager");
context.startActivity(intent);
} catch (Exception exx) {
ex.printStackTrace();
}
}
}
}
OPPO的自动启动
if (Build.MANUFACTURER.equalsIgnoreCase("oppo")) {
try {
Intent intent = new Intent();
intent.setClassName("com.coloros.safecenter",
"com.coloros.safecenter.permission.startup.StartupAppListActivity");
startActivity(intent);
} catch (Exception e) {
try {
Intent intent = new Intent();
intent.setClassName("com.oppo.safe",
"com.oppo.safe.permission.startup.StartupAppListActivity");
startActivity(intent);
} catch (Exception ex) {
try {
Intent intent = new Intent();
intent.setClassName("com.coloros.safecenter",
"com.coloros.safecenter.startupapp.StartupAppListActivity");
startActivity(intent);
} catch (Exception exx) {
}
}
}
}
这篇关于如何以编程方式启用自动启动和浮动窗口权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!