How to enable AutoStart option for my App in Xiaomi phone Security App programmatically in android

Shamili Rani picture Shamili Rani · Sep 7, 2016 · Viewed 10.6k times · Source

My App is working with good remarks in all mobile except MI. Because MI restricting my App background service to run. After enabling App in Autostart in Security, it working perfectly. So can I enable that AutoStart Option for my app in MI Security App through programmatically. Please let me know your valuable suggestions.

And My doubt is how whatsapp , facebook and many more apps default enabling Autostart Option in Security App in Xiaomi?

Thanks in Advance.

Answer

Mohit Mathur picture Mohit Mathur · Jan 17, 2017

Try this...it's working for me. It will open the screen to enable autostart.

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