Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

BroadcastReceiver stop working on Xiaomi after couple of hours

I'm using Awareness API for my project and receiving actions via BroadcastReceiver. This is the question with my code: link. The problem is that everything works fine in all android version except in Xiaomi devices. Where BroadcastReceiver not receiving anything after couple of hours. I have tried many solution for this (such as this and this and turning battery saving off for my app), but nothing seems to work.

like image 328
Dim Avatar asked Jul 11 '18 07:07

Dim


1 Answers

Google Awareness:

And whilst doing so, the API collates data from multiple sources to ensure that the data provided is both accurate and of a high quality. It also takes into account both the power and memory consumption when accessing these signals - helping to ensure that the battery life and memory usage of our applications do not have a detrimental effect on the users device.

As this paragraph says:

It also takes into account both the power and memory consumption when accessing these signals

and you say:

The problem is that everything works fine in all android version except in Xiaomi devices. Where BroadcastReciver not receiving anything after couple of hours

after couple of hours device may going to save more energy

You are listening for "Fence API" to register for changes in the users current environment it may consumes power and thus you do not receive broadcasts you may need to change the device settings to allow using of sensors such as location GPS and other relevant sensors

like image 121
ygngy Avatar answered Oct 25 '22 02:10

ygngy