How to programmatically enable autorun and pop-ups

How to enable auto start permission programmatically? How to find on which phone do I need to autostart the code? How to check autorun permission on or off?

I can only find about popup resolution with canDrawOverlay() permission. "

please help, I searched a lot, I want to enable autorun for the device, if it is not included. Some solutions I found as shown below


I found the code for xiaomi, honor and letv, but I want the same 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); } 
+15
android android-permissions autostart
source share
2 answers

** The following two solutions for Oppo and Vivo may solve your problem, it worked for me **

Please check the following solution to enable floating window resolution on an 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(); } } } } 

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

Autostart 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) { } } } } 
+6
source share

The autostart function will turn on automatically when you download the application from the playstore, if the xiaomi operating system wants it, so that applications such as amazon, google IO, etc., also did not have the right to autostart. In this case, you need to go to the section Security permissions → autorun → then enable autorun from there. You cannot autostart the application by code, all you can do is show a dialog box to enable autostart and transfer the user to autostart operation, but this is not a good option, since you cannot check whether autostart works. included or not.

This is done by Mi in MIUI8 to save battery. This question wasted my 2 days XD

Link

You can refer to the MIUI8 article

+9
source share

All Articles