Why your phone keeps killing your mileage tracker (and how to fix it)
Most mileage apps stop recording after a few hours because Android's battery management silently kills them. Here's why it happens and what to do about it.
You drove to a client. You know you drove. The sat nav remembers. Your body remembers the M25. But when you open your mileage tracker that evening, it shows nothing. No journey. No distance. No record that you ever left the house.
Sound familiar? If you've used any GPS mileage tracker on Android for more than a week, you've probably seen this at least once. And if you drive for a living, you've probably seen it enough times to wonder whether the whole concept of automatic mileage tracking actually works.
It does. But your phone is actively working against it.
It's not the app. It's the phone.
Here's the thing most people don't realise: when a mileage tracker "stops working", it usually hasn't crashed. It hasn't run out of memory. It hasn't hit a bug. The phone's operating system has deliberately killed it to save battery.
Android has always had background limits. That's reasonable. You don't want fifty apps running GPS in the background draining your battery by lunchtime. But over the past five or six years, phone manufacturers have stacked their own battery management systems on top of Android's built-in ones, and these are far more aggressive than what Google intended.
Samsung has "Background usage limits" in Device Care. Xiaomi has "Battery saver" with an auto-cleanup feature that kills apps it considers unused. OnePlus has "Battery Optimisation" that aggressively suspends background apps after a few minutes. Huawei and Honor have "App Launch" controls that override the app's own foreground service requests. Oppo and Realme have their own version of the same thing.
Every one of these systems does essentially the same thing: if an app is running in the background for "too long", and the manufacturer's heuristics decide it's not important enough, it gets stopped. No warning. No notification. The app just dies.
For a mileage tracker that needs to record GPS points continuously for a 90-minute drive, this is a disaster.
The three layers working against you
Modern Android actually has three separate mechanisms that can kill a background app. Understanding them helps explain why the problem is so persistent and why a single settings change often isn't enough.
App Standby Buckets (since Android 9): Android assigns every app to a bucket based on how recently and how often you've used it. Apps in the "rare" bucket get severely restricted background time. A mileage tracker you only open once a week to check your totals can land in this bucket despite running a foreground service.
Doze mode: When the phone's been stationary and screen-off for a while (sitting on your desk, charging overnight), Android enters Doze and defers background work. This one mostly doesn't affect driving (the phone is moving), but it can interfere with tracking restart logic when you get back in the car after a long stop.
OEM battery managers: This is the big one. Samsung, Xiaomi, OnePlus, Huawei, Oppo, and others each add their own battery management layer that operates independently of Android's standard rules. These are the ones that vary wildly between manufacturers and between phone models. They're also the ones that change behaviour with firmware updates, so a phone that tracked fine last month might stop tracking after an OTA update.
The combined effect is that a mileage tracker can be granted every Android permission, be set to "unrestricted" battery, have a visible foreground notification, and still get killed. Because the OEM's battery manager doesn't care about any of that.
How to fix it
The single best resource for this is dontkillmyapp.com. It's maintained by the developers of Sleep as Android (they've been fighting this battle since 2015) and it has step-by-step instructions for every major manufacturer. If you're going to bookmark one page from this article, make it that one.
But the short version, for the most common phones:
Samsung (Galaxy S/A series, Fold, Flip): Go to Settings, then Battery and device care, then Battery, then Background usage limits. Remove your mileage tracker from the "Sleeping apps" and "Deep sleeping apps" lists. Also check that "Adaptive battery" isn't putting it to sleep. In Device Care, make sure the app isn't being flagged as unused.
Xiaomi / Redmi / POCO: Settings, Apps, then find the mileage tracker. Under Battery saver, set it to "No restrictions." Also go to Settings, Battery, then Battery saver, and make sure the app isn't in the auto-cleanup list. On MIUI, you may also need to lock the app in the recent apps tray (swipe down on the app card to pin it).
OnePlus: Settings, Battery, Battery optimisation. Find the app and set it to "Don't optimise." OnePlus is particularly aggressive with apps that haven't been opened recently.
Huawei / Honor: Settings, Battery, App launch. Find the app, disable "Manage automatically", and toggle on all three options (Auto-launch, Secondary launch, Run in background).
On every phone, regardless of manufacturer: go to Settings, Apps, find the mileage tracker, then Battery, and set it to "Unrestricted." This is the standard Android setting and it's necessary but often not sufficient on its own. The OEM-specific steps above are what actually make the difference on most devices.
What KeptMiles does differently
I've spent a genuinely unreasonable number of hours on this problem. You can't stop Android manufacturers from killing background apps (believe me, I've tried asking nicely), so the approach has to be: detect when it happens, restart as quickly as possible, and make it easy for users to fix the underlying settings.
KeptMiles runs a background health check every two hours using AlarmManager (more reliable than WorkManager on Samsung and Xiaomi, which tend to defer periodic work indefinitely). If the tracking service has died while tracking was supposed to be running, the app detects the gap and posts a recovery notification.
On top of that, when you open the app after a silent kill, a red banner appears at the top of the screen telling you that tracking was interrupted. Tap it and you get a recovery screen with one card per detected problem: service killed, notifications blocked, battery optimisation enabled. Each card has a one-tap button that takes you directly to the relevant settings page on your phone. For Samsung, Xiaomi, Huawei, OnePlus, Oppo, and others, these are manufacturer-specific guides with the exact steps for your device.
There's also an automatic restart mechanism. KeptMiles uses Android's Activity Recognition API to detect when you get in a car. If the tracking service has been killed, and Activity Recognition fires a "driving" transition, the app restarts tracking. You lose the first few minutes of the journey (the gap between the kill and the restart), but the rest is captured. It's not perfect. It's a lot better than losing the whole thing.
And honestly, sometimes Activity Recognition itself gets killed by the same battery managers. At which point there's a GPS-based movement detector as a second fallback, checking for significant location changes at low power. Belt, braces, and a bit of string.
The uncomfortable truth
None of this should be necessary. Android has a perfectly good system for foreground services: the app shows a persistent notification, the user granted location permission, and the OS is supposed to let it run. That's the contract. OEM battery managers break that contract, and they do it silently.
Google has been tightening the rules on OEMs in recent Android versions, but enforcement is patchy. Samsung in particular still ships aggressive defaults that affect millions of Galaxy phones. Until that changes, any app that needs continuous background operation on Android (mileage trackers, sleep trackers, dashcam apps, fitness recorders) has to work around it.
The fix from the user's side takes about two minutes. Exempt the app from battery optimisation, check the OEM-specific settings, and it'll track reliably from then on. The frustrating part is that most people don't know they need to do it, because the phone never tells you it killed anything.
If your mileage tracker keeps losing journeys, don't bin the app. Check the battery settings first. It's almost certainly the phone, not the software.
KeptMiles has built-in recovery detection, manufacturer-specific fix guides, and automatic restart when your phone kills the tracker. If something goes wrong, you'll know about it. See the help page for full setup instructions.