Reputation: 3918
I'm to trying to sync operation between two ASUS tablet with Android OS.
I'm currently using this algorithm to do so:
The client tablet sends the time of it's calendar like so:
Calendar cal = Calendar.getInstance();
cal.getTime();
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss:SSSS");
connectionTablet.SendMessage( sdf.format(cal.getTime()) );
The server tablet receives it :
Log.d( "NETWORK", "msg" );
msg is the cal.getTime that was sent from the client, so when I'm debugging the server tablet I can see in the logcat the time at which this message was received and printed.
Both tablet use automatic date & time (Use network-provided time).
My question is this, since the tablets are taking their time info from the same place, I know they have the same time in terms of minutes and seconds, but can I assume that their time is also in sync in term of miliseconds ?
Example:
Tablet 1 : 09:34:07.699 Tablet 2 : 09:34:07.699 (± 5 ms)
So can I assume that this assumption is valid for any point in time ?
Thanks
Upvotes: 2
Views: 212
Reputation: 807
No, as each device has it's own internal clock and these might not run at the exact same speed, that is why the devices will sync themselves from time to time with the network time source, but the "in between" time comes from the internal clock which might be off at some point in time. And that is assuming that the network synchronization is flawless
Upvotes: 3