如何以编程方式启用自动启动权限?
如何查找哪个手机需要执行自动启动代码?
如何检查自动启动权限是启用还是禁用?

我只能找到具有canDrawOverlay()权限的显示弹出式权限。

请帮助我进行了很多搜索,如果未启用该功能,我想启用设备的自动启动功能。我发现了一些解决方案,如下所示



我已经找到了小米,honor和letv的代码,但是我想要联想的东西

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);

            }

最佳答案

请检查以下解决方案以为floating windowautostart permission手机启用OPPOVIVO


  在Oppo设备上


  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) {

                }
            }
        }
}

09-15 22:09