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

后端 未结 3 1745
失恋的感觉
失恋的感觉 2020-12-01 03:11

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

相关标签:
3条回答
  • 2020-12-01 03:29

    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

    0 讨论(0)
  • 2020-12-01 03:32

    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.

    0 讨论(0)
  • 2020-12-01 03:42

    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);
            }
    
    0 讨论(0)
提交回复
热议问题