开发者

How to connect to time server for getting the current time settings? Also is there any time server at all?

My 开发者_JAVA百科Android app requires to get the current date and time from Internet. I can't rely on the date from the phone. How is it possible to get the time from Internet? What are the available time servers?


There are a lot of time servers, the one to select would probably depend on where you are in the wold. You can find a list of the "public" ones at the NTP.org. You can get information on how you need to communicate with an NTP server from RFC958. Just an FYI, I think changing the time on the device would require ROOT permissions.


I have the same problem. It seems as Android have a ntp-client if you look in the logs. But it fails every time... If this had been solved, it had helped many projects/people.

As a workaround I tried this code on Android and i works. This way you can correct your local clock. (You need root access to set it)


The simplest is the daytime protocol assigned to port 13, but only few servers offer this (optional in e.g. Windows NT and later). What do you have available to query against?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜