I'm looking for a way to display GPS-time in my app. What is the easiest way to do this?
(It has to be GPS-time due to slight time differences between gps time and internal system time)
Thanks
The Global Positioning System (GPS) also provides time information via the one-way technique and is the most accurate worldwide one-way time transfer system.
GPS uses its own timescale: “GPS time”. The starting point (time zero) of GPS time was chosen to be midnight of 5-6 January 1980. The GPS satellites transmit the time in two parts: the week number (the number of weeks since time zero) and the elapsed number of seconds within that week.
Automatic time detection receives time suggestions from various sources, selects the best option, and then sets the system clock in Android to match.
Open your phone's Settings app. Under "Personal," tap Location access. At the top of the screen, turn Access to my location on or off.
Whenever you receive a fix from the GPS, the method onLocationChanged
is called. The parameter to this method is an instance of Location
. One of the methods of this parameter is getTime
which will give you what you are looking for. That is if I got right what you are looking for. Read more here
I came across a description of the getTime function that says this:
public long getTime () Return the UTC time of this fix, in milliseconds since January 1, 1970. Note that the UTC time on a device is not monotonic: it can jump forwards or backwards unpredictably.
Yikes! Is that true? Even if it does indeed return a time object that includes the milliseconds value that value is TOTALLY USELESS if it "can jump forwards or backwards unpredictably".
The project that I'm working on absolutely needs an "accurate to the millisecond" time value (even if it's "milliseconds since January 1, 1970"). WIthout that accuracy, I'm screwed!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With