Android 是否使用 NTP 同步时间?

Is Android using NTP to sync time?(Android 是否使用 NTP 同步时间?)

本文介绍了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中,默认的NTP服务器是从Android系统字符串源请求的:

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.

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 同步时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:Android 是否使用 NTP 同步时间?

基础教程推荐