I need two devices to have exact same time. I want to use GPS to get time. It can be done on iOS and Android devices. Can i be sure that they have exact same time in milliseconds?
Asked
Active
Viewed 159 times
2
-
1take a look here, it might explain things better to you http://space.stackexchange.com/questions/5423/how-does-gps-receiver-synchronize-time-with-gps-satellites – Aug 13 '15 at 14:56
-
The answer depends not on the GPS accuracy (ns), but on whether you can directly access the GPS time, how long that can take via software given possible scheduling issues +-ms, how often the GPS time is updated and how does it interpolate in between. If that all comes out at < 1ms then you will be ok. However I doubt that will be the answer. – Rory McKinnel Aug 13 '15 at 15:16
-
Can you be a bit more precise please ? What do you mean by > two devices to have exact same time – David Peicho Aug 13 '15 at 14:58
-
i want to see same values of time in milliseconds on different devices - is it possible with GPS? – moonvader Aug 13 '15 at 14:59
-
Yes, I think it is possible and as @Megatron said it in the comments, you could try to syncrhonize the devices to a satellite. Yes, I think you can do it using the LocationListener class. You just need to use the onLocationChange listener and to use the getTime() function that is part of the location parameter (if I well understood what you are trying to achieve). Take a look at this : http://developer.android.com/reference/android/location/LocationListener.html – David Peicho Aug 13 '15 at 15:12
-
If you read the manual for LocationListener you will notice the time is the time the location was fixed. You have no idea how long it takes to tell you it has updated. There is also no mention of the time being the phone time or the GPS chip time. There are hints it may actually be using the phone clock. Either way, I cant see this being accurate to 1ms on two phones at the same time. – Rory McKinnel Aug 13 '15 at 15:34
-
Al wrong what you tell, At ios the time for location is not the pure GPs time. It is overidden by ios, and shows evrything the user sets. If I set +10 minutes. to real time ios keeps that +10 mintes. – AlexWien Aug 16 '15 at 18:23
1 Answers
0
No you cannot do that easily. ios overrides the gps time. If a user adds one hour, and disables auto time sync, the time is then offset. It will not work that way. If auto time sync is enabled it should work.
However you could query via internet the correct time using a time service, and do the same that NTP do. (network time protocoll). However that looks not to easy.
As an intermediate approach, I would check whether the system time relates to the network time. If yes, one can asume that auto time sync is enabled.

AlexWien
- 28,470
- 6
- 53
- 83