Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 910
Shamili Rani Avatar asked Sep 07 '16 11:09

Shamili Rani


People also ask

How do I get Miui security app auto start permission programmatically?

You need to give permissions in the in build security application for xiaomi. 1. open the security app 2. go to permissions 3. go to auto start 4. enable the applications that you want to keep running in the background!

How do I enable autostart permission in android programmatically?

There's no way to find out whether the Auto-start option is enabled or not. You can manually check under Security permissions => Autostart => Enable Autostart .

What is autostart permission in Miui?

The autostart permission allows apps to be started by receiving an implicit broadcast intent. This method consists of scheduling an implicit broadcast with AlarmManager, killing the app and checking if the broadcast caused it to respawn.


2 Answers

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);         } 
like image 135
Mohit Mathur Avatar answered Sep 21 '22 21:09

Mohit Mathur


Facebook, Whatsapp, Messenger and few more popular apps are whitelisted by Xiaomi. Hence they get enabled by default. Other apps need to be enabled by users. We don't have any other option.

We need to programmatically detect the manufacturer using Build.MANUFACTURER in android and show a dialog which suggests the user to enable the app in AutoStart, if the manufacturer is Xiaomi

like image 29
venkat Avatar answered Sep 23 '22 21:09

venkat