微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

android – 如何从网络提供商获取日期和时间?

有没有办法得到日期&时间从网络提供者以编程方式?可能以与从网络提供商获得位置相同的方式.

解决方法

您可能需要使用自定义NITZ或NTP库

> http://groups.google.com/group/android-developers/browse_thread/thread/d5ce3bcfe17e272b?pli=1

So just a heads up that Android uses NITZ events provided by a carrier
to properly set the system date and time. Android also falls-back to
network NTP automatically when no cellular network is available.

07001

The time provided by currentTimeMillis() will typically be the best
available time,and it’s what all of the services on the device use,
like Calendar and Alarm Clock.

然而

However the NTP API isn’t somewhere that Java code can access,which
means we’re back to using an existing Java NTP/SNTP client library if
we want an accurate time regardless of whether we are on a network
that is NITZ capable.

Java NTP库

您可以从中找到Java NTP库的简单实现

> support.ntp.org

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐