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

十年热恋 提交于 2019-11-27 06:49:35

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

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!