Android 是否使用 NTP 来同步时间? [英] Is Android using NTP to sync time?

查看:25
本文介绍了Android 是否使用 NTP 来同步时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Android 设备是否使用网络时间协议 (NTP) 来同步时间?

Do Android Devices use the network time protocol (NTP) to synchronize the time?

在我的设备设置中,我看到一个带有以下文本与网络同步"的复选框,但我不知道他们是否在使用 NTP.

In my Device-Settings I see a checkbox with the following text "synchronize with network", but I don't know if they are using NTP.

我的学士论文需要这个,我使用 GPS.为了获得准确的 GPS 信号,接收器应该有一个准确的时钟.

I need this for my Bachelor Thesis for which I use GPS. To get an accurate GPS-signal the receiver should have an exact clock.

我在网上找到了这个博客条目,但我不确定他是否说实话:加速 NTP,Android 中的 GPS 锁定

I have found this blog-entry on the web, but I'm not sure if he tells the truth: Speeding up NTP, GPS Lock in Android

推荐答案

我知道 Android ICS 使用名为:NetworkTimeUpdateService.此服务还通过 NtpTrustedTime 单例.

I know about Android ICS that it uses a custom service called: NetworkTimeUpdateService. This service also implements a NTP time synchronization via the NtpTrustedTime singleton.

NtpTrustedTime中,从Android系统字符串源请求默认NTP服务器:

In NtpTrustedTime the default NTP server is requested from the Android system string source:

final Resources res = context.getResources();

final String defaultServer = res.getString(
                                com.android.internal.R.string.config_ntpServer);

如果系统设置中的自动时间同步选项被选中并且没有NITZ时间服务可用,那么时间将与来自com.android.internal.R.string.config_ntpServer的NTP服务器同步.

If the automatic time sync option in the system settings is checked and no NITZ time service is available then the time will be synchronized with the NTP server from com.android.internal.R.string.config_ntpServer.

要获取com.android.internal.R.string.config_ntpServer的值,可以使用以下方法:

To get the value of com.android.internal.R.string.config_ntpServer you can use the following method:

    final Resources res = this.getResources();
    final int id = Resources.getSystem().getIdentifier(
                       "config_ntpServer", "string","android");
    final String defaultServer = res.getString(id);

这篇关于Android 是否使用 NTP 来同步时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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