How to programmatically enable auto-start and floating window permissions, How to find which phone need to do auto-start code?

匿名 (未验证) 提交于 2019-12-03 01:27:01

问题:

How can I enable auto start permission programmatically, please help I have searched a lot ,I want to enable auto-start for device if it is not enabled.Some solutions I have found as below

I have found code for xiaomi,honor and letv but I want same thing for Lenovo

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

回答1:

**Following Two solution for oppo and vivo may solve your problem,this worked for me **

Please check following solution to enable floating window permission on Oppo device

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

Auto Start permission for 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();             }         }     } } 

Auto start for 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) {                  }             }         } 


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!