Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GPS-time in Android

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

like image 907
Andreas Avatar asked Aug 10 '11 20:08

Andreas


People also ask

Can you get time from GPS?

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.

What is GPS time of week?

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.

How does Android automatic time work?

Automatic time detection receives time suggestions from various sources, selects the best option, and then sets the system clock in Android to match.

How do I turn on location all time on Android?

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.


2 Answers

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

like image 150
Ilya Saunkin Avatar answered Sep 21 '22 23:09

Ilya Saunkin


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!

like image 26
Roger Garrett Avatar answered Sep 23 '22 23:09

Roger Garrett