509 timestamp gaps across 159 tracking sessions. That was the number we found when we finally audited what happens to our Android app when the OS kills it in the background.
We run a workforce tracking app on 30 BYOD Android devices. The app needs to record GPS coordinates every few minutes, even when the screen is off. The problem is that Android doesn't want your app running in the background. Between Doze mode, OEM battery optimisations, user force-stops, and reboots, there are at least five distinct ways your app can die without your code ever seeing an exception.
I wrote a preprint that formalises this into a measurement framework: a kill-cause taxonomy, an instrumentation specification, and a classification procedure. The paper and data are open access on Zenodo: DOI: 10.5281/zenodo.24262951.
Five Ways Your App Dies
Most developers know about Doze. Fewer know about OEM kills. The taxonomy from the paper:
1. Doze Kill. Android suspends network and defers alarms after the screen goes off and the device is stationary. Your foreground service keeps running, but your alarms stop firing. The signal: scheduled events stop arriving, but the process is still alive when the user returns.
2. OEM Kill. Huawei's PowerGenie, Xiaomi's MIUI battery saver, Samsung's Sleeping Apps. These are manufacturer-specific processes that kill apps the stock Android wouldn't. On our fleet, a Huawei P30 Lite killed the tracking service 3x more often than a Pixel 4a running the same APK. The signal: process death with no ANR, no crash, and the kill timestamp in the OEM's proprietary log (if you can find it).
3. User Force Stop. The user goes to Settings > Apps > Force Stop. Your app gets no callback. onDestroy does not fire. The signal: sudden silence in all telemetry, and the user has to manually reopen the app.
4. Reboot. Device restarts (OS update, battery death, user-initiated). Your BOOT_COMPLETED receiver fires, but there's a gap between the kill and the restart. On our fleet, the median gap was 4 minutes; the worst was 6 hours (a device that ran out of battery overnight).
5. Permission Revocation. Android 11+ can auto-revoke permissions for unused apps. If your app loses location permission while in the background, the service continues running but gets empty location results. No exception. No crash. Just silence where coordinates used to be.
What We Found in Production
We audited Zontra, a 104,886-line Flutter app deployed on 30 devices over 6 months:
- 6 of 7 signals already existed in the codebase (session start/end, location updates, connectivity changes, app lifecycle, battery level)
- 12 gaps where the existing telemetry couldn't distinguish between kill causes
- 509 timestamp gaps across 159 tracking sessions where the cause couldn't be determined
The biggest gap was classification. We could see the app stopped sending coordinates at 02:14 and resumed at 06:30. Was that Doze? An OEM kill? A reboot? The existing telemetry couldn't tell.
The Classification Procedure
The paper provides a decision tree for mapping observable signals to kill causes. The key disambiguation: Doze kills preserve the process (the app is alive but deferred), while OEM kills terminate it entirely. If your app's onCreate fires on resume, the process was killed. If it doesn't, the process survived and only the scheduled work was deferred.
I haven't tested this on iOS yet. Apple's background execution model is different enough that the taxonomy doesn't transfer directly.
The Paper
Full methodology, taxonomy, instrumentation spec, and validation audit: doi.org/10.5281/zenodo.24262951.
If you're building an Android app that does anything in the background, you're fighting the same problem. The question is whether you've instrumented well enough to know which fights you're losing.
Top comments (0)