How to enable auto start for my app in Xiaomi programmatically

后端 未结 7 1279
情话喂你
情话喂你 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:04

    @rajkumar is right, but you have to take care with Xiaomi running pure Android, MI A1, MI A2 and MI A3 is coming, so you should add something like:

    if (Build.MANUFACTURER.toLowerCase().contains("xiaomi") 
    &&
    !Build.MODEL.toLowerCase().contains("mi a")){
     //intent
     }
    

提交回复
热议问题