The pin has to move after the app leaves the screen

What does this piece decide?

A chauffeur opens Google Maps for the next turn. Android pauses a normal location watch. On an active trip the driver app keeps sending points from a foreground service, and holds the ones the network would not take.

The chauffeur is on a trip and opens Google Maps for the next turn. The driver app is no longer the screen. A location watch tied to that screen stops. The rider is still looking at the pin.

While the app is the screen

The first path is a screen watch. It asks for a fix every second, including when the car is stopped, and writes the durable point every five seconds. That path is enough while the chauffeur is looking at the driver app. It is also the only path while they are online and waiting for a request. There is no trip yet, so there is no rider pin to keep alive.

A task, and the service that keeps it

Once a trip is active, the app starts a background location task as well. Defining the task names the hook Android will call. The start call is what attaches a foreground service, with a notification the chauffeur can see: location tracking is active. Updates stay on, and the service is asked to remain if the activity is destroyed. When the chauffeur comes back, the screen watch starts again.

An active trip. Maps takes the screen. The task keeps the pin moving.

The same fix then splits. A live point goes to the rider on a short interval. A durable point, every five seconds, updates the driver row and the trip history. A live point older than fifteen seconds is dropped. It is no longer where the car is.

Which path runs, and which write it feeds.

The phone can still refuse

Android will still pause the work if the app is battery-optimized. The driver app asks for unrestricted battery once location is ready. Xiaomi, Redmi, Poco, Oppo, Realme, OnePlus, Vivo, and iQOO get a further prompt into that maker's own settings. Stock Android and Samsung stop at the system battery dialog. A bubble over other apps is how the chauffeur gets back from Maps. The service is what keeps the points coming.

Then the network goes

A failed live send stays in memory and is tried on the next fix, until that point is fifteen seconds old. The durable write is the one that has to survive a dead stretch. It sits on the phone: sixty points, twelve tries, and anything older than an hour is dropped. A 401 or 403 refreshes the session stored for the background task and sends again. A history write for a ride that is no longer active is discarded. When the network returns, the next fix flushes what is still waiting.

A live point expires quickly. A durable point waits on the phone.

The service is up before Maps opens, because the trip is already active. The points that could not leave the phone are still on it when the road has a signal again.

Put the idea to work

Turn clear thinking into a production decision.

Bring the product, platform, or operating constraint. We’ll help make the next move concrete.