Android AlarmManager.setExactAndAllowWhileIdle() and WakefulBroadcastReceiver Not working in some new manufactured and low price devices

后端 未结 4 1557
北恋
北恋 2020-12-23 12:09

I think this question is asked many time in stackoverflow but still so many people struggling to resolved it.

In my android app I have to wake up device

4条回答
  •  不知归路
    2020-12-23 12:31

    In my android app I have to wake up device for every 15 min to getting current location and send it to server. I have tested it on Xiaomi Mi 5s (Android 6.0.1). When I close the application, the application goes to sleep :( AlarmManager with setExactAndAllowWhileIdle() not working ¯\_(ツ)_/¯

    Yes, it's working fine in almost all standard/popular devices like Samsung, LG (Nexus 5X), Sony, Motorola, Pixel...

    MY SOLUTION:

    The manifest entry for each type of component element — , , , and — supports an android:process attribute that can specify a process in which that component should run.

    You need add this string android:process=":service" in your AndroidManifest.xml

    Like this:

    ... 
    
    
    
    
    
    
    
    ...
    

    I have tested this solution on Xiaomi Mi 5s. It's work !!!

    IMHO it seems that the Xiaomi firmware kills the main process whenever the user exits the application...

提交回复
热议问题