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

后端 未结 3 1832
失恋的感觉
失恋的感觉 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: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);
            }
    

提交回复
热议问题