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

3

26

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.

Mahratta answered 7/9, 2016 at 11:7 Comment(1)
Please refer attached link for reference #49473730Fib
S
27

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);
        }
Swordplay answered 17/1, 2017 at 12:20 Comment(10)
Its working fine, but App is crashing(Automatically closing) if I Enable -> Disabled app from AutoStart list.Mahratta
Note that I found Redmi Note 3 (Android 5) has annoying bug which Autostart page requires user toggle off -> back -> toggle on to make it work after uninstall then reinstall the app (reinstall without uninstall no such issue). The second bug is if user toggle off the app, it will close the page and exit the app.Abidjan
I detect miui with: val isMIUI = (Class.forName("android.os.SystemProperties") .getMethod("get", String::class.java) .invoke(null, "ro.miui.ui.version.code") as String? ?: "") != "" Because, a xiaomi device might not always be running miui, and miui might not always be running on a xiaomi, considering custom roms and unofficial ports, and their recent mi A1 with stock android.Brahui
Hi all but how to check if autostart permission already enabled or not. Because if we use above code it will call every timeEstes
@Estes how to check autostart permission already enable or not ?Diarist
Is there a way to detect whether it is enable or not by user @Mohit Mathur ?Hussy
@AkashSingh, have you got a solution?Skier
@KishanSolanki124, any solition for thisSkier
@Skier sorry, not yet.Hussy
there is no Android API to check if the the AutoStart is enabled or not. Though you can have you logic (may be you can use preference to set a Boolean for it) to check this. Please have a look here : https://mcmap.net/q/37429/-android-how-to-enable-autostart-option-programmatically-in-xiaomi-devicesAttemper
S
10

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

Spirograph answered 13/9, 2016 at 18:33 Comment(7)
I am facing this issue for long days and also posted in SO #49473730.. Can you pls mention some reference links annotating that Xiaomi allows popular apps ? I would like to share the same to our clientUrge
You can manually check that in any Redmi mobile. You can simply install any Facebook app, it will be whitelisted by default where other apps won'tSpirograph
Is there a way to check if the device allows the app to run on boot?Mitchelmitchell
No. They don't provide any API to check that.Spirograph
@RakeshL Have you found a solutions for how to check if it is enabled?Anatomize
@Anatomize As Venkat commented, there is no Android API to check if the the AutoStart is enabled or not. Though you can have you logic (may be you can use preference to set a Boolean for it) to check this.Attemper
Please refere attached link for reference #49473730Fib
G
0

There is some other way. Install Aarogya setu app, app already has Auto-start permission. It seems, there is a way to whitelist apps for Autostart from online portal of manufacturer.

Gesticulation answered 1/5, 2020 at 13:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.