|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectandroid.net.SntpClient
public class SntpClient
Simple SNTP client class for retrieving network time. Sample usage:
SntpClient client = new SntpClient();
if (client.requestTime("time.foo.com")) {
long now = client.getNtpTime() + SystemClock.elapsedRealtime() - client.getNtpTimeReference();
}
| Constructor Summary | |
|---|---|
SntpClient()
|
|
| Method Summary | |
|---|---|
long |
getNtpTime()
Returns the time computed from the NTP transaction. |
long |
getNtpTimeReference()
Returns the reference clock value (value of SystemClock.elapsedRealtime()) corresponding to the NTP time. |
long |
getRoundTripTime()
Returns the round trip time of the NTP transaction |
boolean |
requestTime(String host,
int timeout)
Sends an SNTP request to the given host and processes the response. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SntpClient()
| Method Detail |
|---|
public boolean requestTime(String host,
int timeout)
host - host name of the server.timeout - network timeout in milliseconds.
public long getNtpTime()
public long getNtpTimeReference()
public long getRoundTripTime()
|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||