Timestamp synchronization on multiple devices

I am trying to synchronize timestamps between several Android devices, so I can run the task at the same time. I believe that I can use Timer and set the date based on System.currentTimeMillis (), but the problem is that the timestamps of several devices are far enough apart that I do not get the accuracy I want.

I look somewhere in the range of 50-100 ms, if possible. One of my ideas was to use Android Beam to send one deviceโ€™s timestamp to another device and then calculate the delta, but it turns out that I need to get the timestamp before the message is actually sent and received (i.e. The longer the user waits for dispatch, the greater the delta will be), which makes this scheme completely fall apart.

How can I synchronize two or more devices so that their internal clocks are no more than 100 ms apart? Is this even possible without using an external server that saves time?

Any other suggestions on how to use something on multiple devices as close to each other as possible will also be welcome.

+8
android
source share
4 answers

Why not use GPS time? GPS timestamps are pretty accurate.

You can pair all devices at a specific time, and then launch it when GPS informs you.

+4
source share

In fact, you have two options: the easy way or the hard way.

A simple way is to use one external source for time signals, such as NIST , another Internet source or GPS like @, says Stefan. Internet sources use NTP, see This Java NTP Client .

The difficult way is to synchronize the clock between devices.

+2
source share

I am struggling with the same problem right now. I tried gps time, but I can not guarantee that the user will have a gps signal in the room.

My solution was for all devices to retrieve time from the nist server and then just add or subtract the time difference using System.currentTimeMillis ()

If the devices are rooted, you can try to synchronize the clock.

https://play.google.com/store/apps/details?id=en.org.amip.ClockSync&hl=en

0
source share

Android GPS equipment usually only has second accuracy. The last three digits of a millisecond floating point number are 000.

0
source share

All Articles