Add my app to AutoStart apps list in android programmatically

asmgx picture asmgx · Jan 22, 2017 · Viewed 13.3k times · Source

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

Answer

Karan sharma picture Karan sharma · Apr 3, 2018

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