Sync Android devices via GPS time?

You can get the time difference in milliseconds from currentTimeMillis() and Location.getTime() in the onLocationChanged() callback. Use requestSingleUpdate()


I just want to add that, if the user has a data connection they can use NTP time, which is even more accurate, as the GPS internal clock might drift and correcting it takes a while.


EDIT:
I want to edit this answer. After working as a GNSS developer in Android OS I realized that many ‘major’ Android OEMs have messed this up.
Usually NMEA sentences are generated at the chipset or GNSS stack. Sometimes the time is right, it depends on the implementation.

Also there is a problem of leap second. GPS time is not UTC time. And as of this writing it is 18 seconds ahead.

Also GPS time fromLocation objects are now system time as per the documentation

TLDR : use NTP time

Leave a Comment