@UnstableApi
class SntpClient


Static utility to retrieve the device time offset using SNTP.

Based on the Android framework SntpClient.

Summary

Nested types

Callback for calls to initialize.

Constants

const String!
DEFAULT_NTP_HOST = "time.android.com"

The default NTP host address used to retrieve getElapsedRealtimeOffsetMs.

const Int

The default maximum time, in milliseconds, to wait for the SNTP request to complete.

Public functions

java-static Unit

Starts loading the device time offset.

Public properties

java-static Long
@GuardedBy(value = "valueLock")
elapsedRealtimeOffsetMs
java-static Boolean
@GuardedBy(value = "valueLock")
isInitialized
java-static Long
@GuardedBy(value = "valueLock")
maxElapsedTimeUntilUpdateMs
java-static String!
@GuardedBy(value = "valueLock")
ntpHost
java-static Int
@GuardedBy(value = "valueLock")
timeoutMs

Constants

DEFAULT_NTP_HOST

const val DEFAULT_NTP_HOST = "time.android.com": String!

The default NTP host address used to retrieve getElapsedRealtimeOffsetMs.

DEFAULT_TIMEOUT_MS

const val DEFAULT_TIMEOUT_MS = 1000: Int

The default maximum time, in milliseconds, to wait for the SNTP request to complete.

Public functions

initialize

java-static fun initialize(loader: Loader?, callback: SntpClient.InitializationCallback?): Unit

Starts loading the device time offset.

Parameters
loader: Loader?

A Loader to use for loading the time offset, or null to create a new one.

callback: SntpClient.InitializationCallback?

An optional InitializationCallback to be notified when the time offset has been initialized or initialization failed.

Public properties

elapsedRealtimeOffsetMs

@GuardedBy(value = "valueLock")
java-static val elapsedRealtimeOffsetMsLong

isInitialized

@GuardedBy(value = "valueLock")
java-static val isInitializedBoolean

maxElapsedTimeUntilUpdateMs

@GuardedBy(value = "valueLock")
java-static var maxElapsedTimeUntilUpdateMsLong

ntpHost

@GuardedBy(value = "valueLock")
java-static var ntpHostString!

timeoutMs

@GuardedBy(value = "valueLock")
java-static var timeoutMsInt