How to enable auto start for my app in Xiaomi programmatically

后端 未结 7 1239
情话喂你
情话喂你 2020-12-01 01:20

I have a service in my app which needs to be running in the background all the time. On all devices, it\'s working fine except Xiaomi. I have read somewhere that we need to

相关标签:
7条回答
  • 2020-12-01 02:20

    you can do it by following:

          if (manufactXiaomi.equalsIgnoreCase(android.os.Build.MANUFACTURER)) {
            if (!session.getVisibilityOfAutoStartDialog()) {Intent intent = new Intent();
                intent.setComponent(new ComponentName("com.miui.securitycenter", "com.miui.permcenter.autostart.AutoStartManagementActivity"));
                startActivity(intent);}}
    

    if you want to keep running your service is the background you need to change some setting of your device Check This

    might above code works for you

    0 讨论(0)
提交回复
热议问题