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

前端之家收集整理的这篇文章主要介绍了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

原文链接:https://www.f2er.com/android/312875.html

猜你在找的Android相关文章