androidandroid-locationandroid-fusedlocation

Discrepancy between Google Maps Timeline and getLastLocation() in Android app


I've developed an Android application that calls the getLastLocation() function to record coordinates every minute.

However, I've observed a discrepancy between the coordinates logged by Android Google Maps Timeline and those acquired through getLastLocation().

During the journey from point A to point B, getLastLocation() consistently returns the coordinates of point A, without any updates. Meanwhile, Google Maps Timeline records multiple distinct points within the same timeframe.

If Google Maps is able to request and receive new locations, I would expect to retrieve them using getLastLocation(). However, it consistently returns the old point A coordinates.

What could be the reason behind this behavior? Any insights would be greatly appreciated. Thank you.


Solution

  • There may be difference between the coordinates logged by Android Google Maps Timeline and those acquired through getLastLocation() since it doesn't guarantee to be latest.

    Inefficiency of getLastLocation ?

    Filtering and Smoothing:

    Timeliness:

    Solution :

    In that case either request location update or use getCurrentLocation().

    If a client needs the current location of the device and is checking to see if a cached location is recent enough to be useful, but will need to calculate a new location otherwise, clients are recommended to use getCurrentLocation(CurrentLocationRequest, CancellationToken) which can take advantage of a cached location or calculate a new location if necessary in a single method call.


    Why Google Map is accurate ?

    Reason is that Google Maps collects the data from several sources like GPS, Wi-Fi and information related to cell towers. It may collect and store your data for different reasons including but not limited to enhancing location precision, offering personalized recommendations among others even when you are not logged into any account with them; however they do so for advertising as well.

    Google Map accuracy :

    https://techbeacon.com/security/google-tracks-your-location-even-when-you-tell-it-not

    https://www.cnet.com/tech/mobile/google-is-probably-tracking-your-location-even-if-you-turn-it-off-says-report/

    Reference link for location update: