java - Get time of NTP-Server from Android App -
dear android developers,
i'm trying implement sntpclient class in application didn't work.
in code have following lines:
public void onclickbtn(view v) { sntpclient client = new sntpclient(); if (client.requesttime("pool.ntp.org", 10)) { long = client.getntptime() + systemclock.elapsedrealtime() - client.getntptimereference(); toast.maketext(this, "offset: " + now, toast.length_long).show(); } }
i don't know meaning of network timeout in case.
it great, when has idea or tip me.
thanks in advance!
you should put in asynctask :
class getntpasynctask extends asynctask<string, void, boolean> { @override protected boolean doinbackground(string... params) { private sntpclient sntpclient = new sntpclient(); return sntpclient.requesttime("pool.ntp.org", 30000); } }
timeout: network timeout in milliseconds. use 30000 mean 30 seconds.
Comments
Post a Comment