When Android stops your tracker
Why Android sometimes stops a walk or hike recording in the background, which phone settings prevent it, and how to tell when it happened.
· Malik · 6 min read
You start recording at the car park, put the phone in your pocket and walk for three hours. At the top you look at the map, and the track ends somewhere in the forest. Or it jumps in a straight line from the second hut to the summit. Your phone stopped the app while you walked.
This happens to every kind of tracker, not just one app, and on a run as much as on a walk. Whichever app you use, most of the remedy is in your phone's settings. What the settings can't prevent, the app has to survive, and for that part I'll take walker, the walk, hike and ride tracker I make for Android, as the example.
What it looks like
- The recording stops early, and the rest of the walk or run is missing.
- A straight line cuts across the map where the track should wind along a path.
- The app's notification, which shows while it records, is gone from the top of the screen.
- When you open the app again, it starts fresh, as if you never pressed record.
Why Android closes apps
Android limits what apps do in the background, to save battery. On recent versions, each app has a Battery usage page in the system settings with three choices. "Unrestricted" allows all background work, which might use more battery. "Optimized", the default, limits background work based on how you use the app. "Restricted" means the app can't run in the background at all.
A foreground service is Android's name for an app that keeps working after you leave it, with a notification showing. That is how a tracker keeps recording with the screen off, and the recording notification at the top of your screen is the sign of it. Android's documentation says a restricted app can't start one. Android can also suggest restricting an app it thinks is using too much.
Some phone makers go further than Android itself. They "prefer battery life over proper functionality" of apps, as the site dontkillmyapp.com puts it, and it counts health trackers among the most affected. At the time of writing, its ranking of the worst offenders starts with Huawei, Xiaomi, OnePlus, Samsung and Meizu.
Set battery use to Unrestricted
Set your tracker's battery use to Unrestricted in Android's settings for the app: a tracker records for hours with the screen off, and that is exactly the background work it needs. It is the most useful single change. On some phones the choice is called "Don't optimize" instead.
Check your phone maker's own settings
Look up your phone maker's page on dontkillmyapp.com and follow its steps, because many makers add a battery saver on top of Android's. Their names change from one model and version to the next, so treat these three as examples.
Samsung
On some versions, Samsung keeps lists of "Sleeping apps", "Deep sleeping apps" and "Never sleeping apps" under Battery → Background usage limits. Put your tracker under "Never sleeping apps", and consider turning off "Put unused apps to sleep". Samsung may add apps back to the lists after an update.
Xiaomi
Turn on Autostart for the app, and set its battery saver to "No restriction". You can also lock the app in the recent apps screen by dragging it down.
OnePlus
Set battery optimisation to "Don't optimize", and lock the app in the recent apps screen. The site warns that OnePlus has reset this setting for some apps.
Leave it in the recent apps screen
Don't swipe your tracker away in the recent apps screen while it records. A swipe normally doesn't close an app, the site explains, but on some phones, OnePlus among them, it may close it completely. Where your phone can lock an app in the recent apps screen, do that for your tracker.
Allow location all the time if you want the recording to resume
Allow your tracker location "all the time" if it offers to carry on a recording after Android has closed it. That is the one case where it needs the permission. For recording with the screen off, it doesn't.
Android gives apps location in two ways. An app on screen is using location in the foreground. An app that keeps its recording notification up counts as foreground too, and it keeps that access when you press Home or turn the screen off. Anything else is background location, and that has a separate permission. On Android 11 and later you can't grant it from the usual pop-up: you choose "Allow all the time" on the app's location page in the settings.
When Android has closed the app, the notification is gone with it. To carry on recording before you open it again, the app needs background location.
How walker handles it
walker is built so that what it has recorded survives when Android closes it.
While you record, walker keeps its notification up. It shows the time and distance, with Pause, Resume and Stop, so you can put the phone away. The Stop button in the notification opens walker and asks first. Every point is written to the phone as it arrives, before walker does anything else with it. If Android closes walker, or the battery dies, the walk so far is stored.
What happens next depends on one setting. With Keep recording if Android closes walker, in Settings → Recording, the recording carries on by itself, usually within seconds. It needs location access set to "Allow all the time", and it is off unless you allow it. walker uses that permission only to carry on a recording you started. Setup offers it once, on the In the background page.
Without it, the next time you open walker it shows Unfinished recording, with where you got to. Resume carries on and counts the gap as a pause. Finish saves the walk as it is.
Swiping walker away while it records counts as closing it: with the setting on, the notification comes back and the recording continues.
If walker is closed often during walks, set its battery use to Unrestricted, as above. The help page's section on what happens if Android closes walker has the steps in brief.
Before your next walk or run
- Set your tracker's battery use to Unrestricted, or "Don't optimize".
- Check your phone maker's battery saver as well.
- Don't swipe the tracker away while it records.
- If your tracker offers it, allow location "all the time" for recordings that carry on by themselves.
- Glance at the notification now and then. If it's gone, the recording may have stopped.
None of this needs doing on the day. You make these settings once, at home, and look at them again after an update, because some phones, Samsung's among them, put them back. From then on the phone in your pocket is far more likely to do what you asked of it at the car park: keep recording until you tell it to stop.