开发者

Get device and user independent time in android

In m,y android application i would like to use time which do not come from device but a standard time that the user cannot change. 开发者_开发问答Is there any way to do this.

Please share your valuable suggestions.

Thanks in advance:)


You can use NTP for fetching the time from any of the public NTP servers. You can read the example SNTP client code for java here.


I'm unclear on the question here. The time on the phone in almost all (maybe all?) cases will be from the network, which will be the official time. If you need it in a different time zone that shouldn't be a difficult conversion.


If you don't mind the overhead, you could make a request to a time server for the official time. I'm sure there's one out there somewhere that accepts JSON or webservice requests.


This will give you the current time:

System.currentTimeMillis();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜