phones put the app in background mode when the app is not active for some time

mohammed shafeeq6 years ago

The expected behaviour of the app will be running all the time when it's in ON state. Some phones put the app in background mode when the app is not active for some time. I want the app to be running all the time when in on state. please help..

Anton Tananaev6 years ago

You need to add the app into battery optimisation exceptions list.

mohammed shafeeq6 years ago

is there any option to do that (add the app into battery optimisation exceptions list) with code ?

Anton Tananaev6 years ago

No.

Chip6 years ago

I think there is something else. I use the hidden 5.16 Android version. The app was placed manually on the Unmonitored apps list so it can use as much power as it wants. OS Location is on High Accuracy. App Location Accuracy is Medium. The phone reports location once every 30 seconds and sits on a desk for a while without user interaction. Everything is green. After about 2 hours there is no more reporting shown on server. I unlock the home screen and get to the app's Status. I see the 2 hours idle time without any any line in the log and the latest log entry entered just now: Location Update, followed 2 seconds later by Network Online and Send Failed. 30 seconds later I see Location Update and server map icon turns green. From that moment everything runs ok, but after 2 hours of idle time.... etc.
So at this point I believe it is not battery but something else, maybe related to network. The phone is on LTE all the time, signal i s strong and internet available.

Chip

davejh6 years ago

Did you find a solution Chip

Chip6 years ago

No solution yet. What I observed with one particular LG Rebel is that if after I factory reset this phone and leave untouched the installed default apps, the Traccar client would work as intended, in background without being interrupted. The difference is that I disabled notifications from all other non-Traccar applications, since I didnt need anything else to bother on this phone. But apparently notification activity from other apps helped Traccar client to stay awake.

Chip

Anton Tananaev6 years ago

Check this website:

https://dontkillmyapp.com/

Chip6 years ago

I am aware about it. LG is not listed there.
They pretty much suggest removing app from battery optimization app list, which obviously I did.

Chip