title: Sync Android devices via GPS time?
body: <p><strong>Short version:</strong></p>
  
  <p>Problem: I need several Android devices to do something at the exact same time (within ca 100 milliseconds). For example, I want all devices to play a certain sound at previously determined point in time.</p>
  
  <p>Question: Could I use GPS time to make sure the devices clock's are synced?</p>
  
  <p><strong>Longer version:</strong></p>
  
  <p>Several people having Android devices are in the same outdoor location (for some specific sports event). All devices should signal certain events at the exact same time. (What time will be determined before hand and it is not important that they do it at exactly that time, as long as they do it at the same time). FWIW: those events will help the people to start their sporting activity at the same time.</p>
  
  <p>Here are assumptions I can make:</p>
  
  <ul>
  <li>There may or may not be cell coverage. (It is outdoors and may be far of urban areas)</li>
  <li>The devices may or may not be connected to the internet. (Some people might not have a data plan)</li>
  <li>Devices can talk to each other. If the devices are not connected to the internet they will be connected via wifi (though the wifi may not have an internet gateway).</li>
  <li>The devices are outside (and not inside buildings). (That's good, it means all devices can get a GPS fix)</li>
  <li>The devices are physically close to each other (i.e., within 300 m2). (Not sure if that's important)</li>
  </ul>
  
  <p>I cannot use the internal clock to know when to play events: users can manually change the time and even if a device is set to get the time from a cellular network, that network might not provide the exact right time. Two devices might be booked into different networks and hence their time might not be synced very well.</p>
  
  <p>At app startup, each device could ask for a GPS fix and save the difference between the GPS time and its internal clock. Now the master could announce events based on this GPS time (by using it's internal clock and substracting the offset it saved earlier).</p>
  
  <p>Will this be precise enough and reliable?</p>
  
  <p>Many thanks in advance,
  Andreas Leitner</p>