Add My App To AutoStart Apps List In Android Programmatically


Answer :

Some of the applications such as Whatsapp and Facebook might have been whiltlisted thats why they have automatic Autostart option enabled.

But i have tried the following code for Xiaomi Devices hope this might help!!

    String manufacturer = "xiaomi";     if(manufacturer.equalsIgnoreCase(android.os.Build.MANUFACTURER)) {         //this will open auto start screen where user can enable permission for your app         Intent intent = new Intent();         intent.setComponent(new ComponentName("com.miui.securitycenter", "com.miui.permcenter.autostart.AutoStartManagementActivity"));         startActivity(intent);     } 

This screen/behaviour is not native to Android, meaning the screen you show comes from a custom rom, probably from a particular manufacturer.

Like you said the answers in the other question do not work but they are the only native way to start an application on boot/start.

Check if the app/custom rom has an API (a particular broadcast receiver to implement, or some SDK...). You can always decompile one of the apps that implement this behaviour to see how they do appear in this menu.


Few popular apps run in background without being killed during memory cleanup cycle (many of the popular OEMs customize the stack ROM for battery/memory optimization), because they are "White listed" by these manufactures. For your app you can whitelist it either manually (via corresponding "settings" for the devices) or pragmatically by redirecting users to the corresponding settings page to white list the app.

Please have a look for details here


Comments

Popular posts from this blog

Converting A String To Int In Groovy

"Cannot Create Cache Directory /home//.composer/cache/repo/https---packagist.org/, Or Directory Is Not Writable. Proceeding Without Cache"

Android How Can I Convert A String To A Editable