获得从网络提供商日期时间? [英] Get datetime from network provider?

查看:122
本文介绍了获得从网络提供商日期时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有什么办法让日期时间从网络提供商编程当我们从网络提供商获得位置?

Is there any way to get Datetime from the Network Provider programmatically as we get the location from the network provider?

推荐答案

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

所以才抬起头的Andr​​oid使用由运营商提供的NITZ事件   正确地设定系统日期和时间。安卓也属于-回   NTP网络时自动无蜂窝网络可用。

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.

http://en.wikipedia.org/wiki/NITZ

的时间通常是最好的   可用的时间,这一切都在设备上使用的服务是什么,   像日历和闹钟。

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.

然而

然而,NTP API不是地方,Java的code可以访问,这   意味着我们又回到了利用现有的Java NTP / SNTP客户端库,如果   我们希望有一个准确的时间,无论我们是否在网络上   这是NITZ能力。

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文库的

You can find a naive implementation of a Java NTP Library from

这篇关于获得从网络提供商日期时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆