20

I want my app to be in the autostart list after installation.

I know when I install an app like (whatsapp) it goes automatically to the autostart list. I want my app to be the same

enter image description here

I tried the code in this question How to Autostart an Android Application?

but unfortunately non of the answers actually made the app autostart.

Not sure if I am doing something wrong

the reason that I need the app be autostart is just to get notifications from the webservice. as the app does not get notifications unless its open or autostart is on

would appreciate your help

thanks

10
  • 1
    As far as I know there is no real autostart for apps. You can register BroadcastReceiver and so on so your app will automatically react to push messages or intents. Most android smartphones don't have the screen you are showing on the screenshot. This is a custom feature which is mostly used to save battery power. Commented Jan 22, 2017 at 13:07
  • 1
    You have to use Broadcast Receiver to start your application when the phone boots. Your question still needs more clarity, to answer I need to know whether you want to start a service (in background) or start an activity (foreground). For either case you will need to add broadcast receiver Commented Jan 22, 2017 at 13:10
  • The screen is from MIUI android.. i thought the same feature exist in all androids so apps like whatsapp can get notifications even though user did not start the whatsapp every time they restart the phone Commented Jan 22, 2017 at 13:20
  • You can try using Broadcast Receiver and check whether it works. Commented Jan 22, 2017 at 13:32
  • 2
    @TheGreat004 No, no one gave a solution for that Commented Sep 1, 2017 at 16:41

4 Answers 4

8

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); } 
Sign up to request clarification or add additional context in comments.

3 Comments

@AbhishekPandya Its depends on your logic but must be before calling the service to get start. Please have a look here: stackoverflow.com/a/56335831/5685911
zomato app also auto start then hpw to auto start own android application please help me friends
how to check for other manufacturers like Infinix ?
5

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

5

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.

Comments

2

I have tried below code to whitelist my app

try { final Intent intent = new Intent(); String manufacturer = Build.MANUFACTURER; if ("xiaomi".equalsIgnoreCase(manufacturer)) { intent.setComponent(new ComponentName("com.miui.securitycenter", "com.miui.permcenter.autostart.AutoStartManagementActivity")); } else if ("oppo".equalsIgnoreCase(manufacturer)) { intent.setComponent(new ComponentName("com.coloros.safecenter", "com.coloros.safecenter.permission.startup.StartupAppListActivity")); //intent.setComponent(new ComponentName("com.coloros.oppoguardelf", "com.coloros.powermanager.fuelgaue.PowerConsumptionActivity")); } else if ("vivo".equalsIgnoreCase(manufacturer)) { intent.setComponent(new ComponentName("com.vivo.permissionmanager", "com.vivo.permissionmanager.activity.BgStartUpManagerActivity")); } else if ("huawei".equalsIgnoreCase(manufacturer)) { intent.setComponent(new ComponentName("com.huawei.systemmanager", "com.huawei.systemmanager.optimize.process.ProtectActivity")); } else { // applySubmit(false); return; } } catch (Exception e) { e.printStackTrace(); } 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.