java - Get time of NTP-Server from Android App -


dear android developers,

i'm trying implement sntpclient class in application didn't work.

class: http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/4.0.3_r1/android/net/sntpclient.java

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

Popular posts from this blog

php - cannot display multiple markers in google maps v3 from traceroute result -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -