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.
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.
Accuracy vs. Frequency: getLastLocation()
is designed to retrieve a single, recent location. In contrast, Google Maps Timeline aims to represent your movement over time even if individual points are less precise; it may employ different sources such as cell towers, Wi-Fi or GPS for frequent data collection.
Battery Optimization: While stationary, battery-saving measures can cause getLastLocation()
not to update regularly. On the other hand, Google Maps Timeline may aggressively collect location data so as not to lose track of movements.
Filtering and Smoothing:
getLastLocation()
readings.Timeliness:
getLastLocation()
has not been updated recently then it will not display the latest current location. And there could be some lag time between when new information becomes available for use by Google Maps Timeline in showing them on its maps.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.
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
Reference link for location update: