So, I'm trying to use an NTP server to help me synchronize an app across two Android devices (to have them perform some action at the exact same time, give or take < 20 ms).
I'm using the SNTP client code here as provided from the StackOverflow post here and it works just fine. The problem is that at the exact instant that the NTP server gets its timestamp, I need to know what time it is locally on my device (so not the time that the device received the returned timestamp, but the actual device time that corresponds to the timestamp from the NTP server). This would mean I'd have a sort of "snapshot" with two different timestamps (one device, one NTP server) that took place at the "exact" same time.
I am having a very hard time figuring this out and am starting to think it's not possible at all (which sort of makes sense). My best effort has been to try and assume that the local device time that corresponds to the time returned by the NTP server would be halfway through the roundtrip request-response time, but even the obvious error there is made even worse the longer the NTP request takes, so that's solution's simply not good enough.
How can I move forward with this on Android?