I'm running a very simple open-source Android GPS tracker:


I have it set to post GPS coordinates from my phone to my server every 30 seconds. The problem is: it sometimes works, and sometimes sleeps for 3 minutes, or 8 minutes, or sometimes seems like it is completely stopped.

What might be causing this and is there anyway to prevent it from happening?

This is not a "secret" app or malicious in anyway; the person running it knows they are running it. I just don't want to make the user re-launch the app every 5 minutes, or even whenever they restart their device (which the code says it supports already).

  • I'm using this on several devices, but my primary phone is a Galaxy S5 running 6.0.1 – Bing Aug 18 '16 at 17:59

The Android OS intentionally tries to prevent applications like this from running to prevent battery drain. For Android 6 specifically, you need to know about the doze and app standby features. Doze prevents applications from running when the device is not in use. App standby defers network activity for seldom-used applications. Both of these are likely affecting your usage.

Running GPS (actual GPS, not just location services), is a huge power drain.

If you don't care about power, you can try:

  1. Keep device on with your application in foreground.
  2. Whitelist your application for doze and app standby (see above link).
  • I'm familiar with these, and I know GPS is one of (if not the) biggest drains on battery. That said, I still want my tracker to be posting updates anyway. Is there no way to force this "stay running" behavior in Android? – Bing Aug 18 '16 at 18:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.