r/mobiledev • • 6d ago

Continues Location tracking Issue

I'm facing a recurring issue with background location tracking on Chinese Android devices (Xiaomi, OPPO, Vivo, Realme, Huawei, Samsung etc.).

Location tracking starts successfully but automatically stops after some time, even when the required permissions are granted.

Interestingly, the same implementation works perfectly on iOS and stock Android devices.

I've tried multiple solutions, but the issue keeps coming back.

**Has anyone found a reliable, production-ready solution for continuous background location tracking across different Android OEMs?**

I'd love to hear your real-world experience and suggestions. Thanks!

5 Upvotes

3 comments sorted by

2

u/MobileXapps 6d ago

On those devices there isn't a code-only fix, the vendor's battery manager kills the process regardless of the permissions. What helps most: run tracking in a foreground service with type location and a visible notification, use FusedLocationProvider updates inside it rather than WorkManager or alarms, and then walk the user through the vendor's own settings, like autostart on Xiaomi and Oppo, app launch on Huawei, and battery set to unrestricted. dontkillmyapp has the per-vendor steps, which you can turn into in-app screens.

Also detect the gaps instead of hoping. If the server stops getting points, show the user that tracking was paused and why, and log the device model. Then you'll know which vendor and which setting causes most of the drop.

1

u/Waste-Start4406 5d ago

Have you checked the Don't Kill My App site? It lists the exact battery settings each OEM messes with, and Xiaomi and Huawei are some of the worst