6

In my android app I read GPS data and GPS time. For some reason GPS returns tomorrow's date. Anybody knows why?

I get data like this: (it was always good). Bug in 4.0.3?!

position.GPSTime = new Date(loc.getTime());

enter image description here

EDIT

I keep ALL times in UTC. This app being in production for 1 year - results I'm showing from 1hr ago and you can see they are UTC times. On a left - time reported by device and on a right - time from location service. I'm not confusing anything, those dates usually 1-2 seconds apart.

EDIT 2

See shot from my debugger from my phone!! Took 2 minutes ago (~10:10 AM CST)

enter image description here

katit
  • 17,375
  • 35
  • 128
  • 256
  • @BicycleDude See my other edit with screenshot from debugger. It is like this for 1 year - worked correct... – katit Jan 27 '12 at 16:14
  • (EDIT OOPS) Okay, position.GPSTime is wrong. Now we need to figure if it's new Date(milliseconds) or loc.getTime() is the source of the error. I'm starting to agree with you that this could well be a Nexus S with 4.0.3 problem. i.e. see if (new Date(milliseconds)).getTime == milliseconds - that will remove one source of error. Then we're left to scrutinize loc.getTime(). BTW It's Jan 28 3:32 AM here in Australia ;) – Stephen Quan Jan 27 '12 at 16:29
  • Well, I would say if it's `new Date(milliseconds)` - it's a major problem then. `location.GetTime()` is much less used in a wild.. – katit Jan 27 '12 at 16:34
  • After finding the fault mentioned on Code Google I removed my obsolete comments and corrected my answer below. – Stephen Quan Jan 27 '12 at 17:06
  • Looks like it is chipset firmware affecting more devices than just 4.0.3 :( It sucks. I did rely on DeviceTime before but that is a bad idea as well since my users have tablets as well and those do not sync with cell provider time so times can be off a lot. I was going to even "validate" device times by using GPS time. Really... – katit Jan 27 '12 at 17:18
  • How about internet time? If it's mission critical I'd probably look at NTP time such as http://hi-android.info/src/android/net/SntpClient.java.html – Stephen Quan Jan 27 '12 at 17:27
  • Will see. Application connects to server anyway, I can just sync with server. Couple seconds off is no big deal. Problem is that I can't programmaticaly change time on device. So, there will be no 100% reliable way to get it right. GPS can be on and network can be off – katit Jan 27 '12 at 17:32
  • some of my users have this problem – Bob Oct 15 '12 at 06:59
  • Is it Android bug or Samsung bug? – Bob Aug 10 '14 at 11:52

2 Answers2

4

Here I gave posted the Solution for the above problem

Android : Samsung Galaxy Tabs and Android 2.2 Devices Showing GPS date 1 Day Advance from 1st jan 2012 In short use the NMEA Listener as an alternative

Community
  • 1
  • 1
3

GPS time is being expressed in Coordinated Universal Time. The reference time is the time in London. You're getting confused with your local time which is in a time zone that's behind UTC time by 1 day.

After much troubleshooting and research, I came across this Code Google article Issue 23937: GPS Provider : android.location.Location.getTime() returns wrong UTC timestamp on 4.0.3 / Nexus S which seems to describe the same symptoms.

Stephen Quan
  • 21,481
  • 4
  • 88
  • 75