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