docs/doc/reference/com/google/android/exoplayer2/util/SntpClient.html
Package com.google.android.exoplayer2.util
[@Deprecated](https://developer.android.com/reference/java/lang/Deprecated.html "class or interface in java.lang")public final classSntpClientextends[Object](https://developer.android.com/reference/java/lang/Object.html "class or interface in java.lang")
Deprecated. com.google.android.exoplayer2 is deprecated. Please migrate to androidx.media3 (which contains the same ExoPlayer code). See the migration guide for more details, including a script to help with the migration.
Static utility to retrieve the device time offset using SNTP.
Based on the Android framework SntpClient.
Nested Classes | Modifier and Type | Class | Description |
| --- | --- | --- |
| static interface | SntpClient.InitializationCallback |
Deprecated.
Callback for calls to initialize(Loader, InitializationCallback).
|
Fields | Modifier and Type | Field | Description |
| --- | --- | --- |
| static String | DEFAULT_NTP_HOST |
Deprecated.
The default NTP host address used to retrieve getElapsedRealtimeOffsetMs().
|
All Methods Static Methods Concrete Methods Deprecated Methods | Modifier and Type | Method | Description |
| --- | --- | --- |
| static long | getElapsedRealtimeOffsetMs() |
Deprecated.
Returns the offset between SystemClock.elapsedRealtime() and the NTP server time in milliseconds, or C.TIME_UNSET if isInitialized() returns false.
|
| static String | getNtpHost() |
Deprecated.
Returns the NTP host address used to retrieve getElapsedRealtimeOffsetMs().
|
| static void | initialize(Loader loader, SntpClient.InitializationCallback callback) |
Deprecated.
Starts loading the device time offset.
|
| static boolean | isInitialized() |
Deprecated.
Returns whether the device time offset has already been loaded.
|
| static void | setNtpHost(String ntpHost) |
Deprecated.
Sets the NTP host address used to retrieve getElapsedRealtimeOffsetMs().
|
-
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
public static final[String](https://developer.android.com/reference/java/lang/String.html "class or interface in java.lang")DEFAULT_NTP_HOST
Deprecated.
The default NTP host address used to retrieve getElapsedRealtimeOffsetMs().
See Also:Constant Field Values
-
public static[String](https://developer.android.com/reference/java/lang/String.html "class or interface in java.lang")getNtpHost()
Deprecated.
Returns the NTP host address used to retrieve getElapsedRealtimeOffsetMs().
-
public static void setNtpHost([String](https://developer.android.com/reference/java/lang/String.html "class or interface in java.lang")ntpHost)
Deprecated.
Sets the NTP host address used to retrieve getElapsedRealtimeOffsetMs().
The default is DEFAULT_NTP_HOST.
If the new host address is different from the previous one, the NTP client will be isInitialized() uninitialized} again.
Parameters:ntpHost - The NTP host address.
-
public static boolean isInitialized()
Deprecated.
Returns whether the device time offset has already been loaded.
If false, use initialize(Loader, InitializationCallback) to start the initialization.
-
public static long getElapsedRealtimeOffsetMs()
Deprecated.
Returns the offset between SystemClock.elapsedRealtime() and the NTP server time in milliseconds, or C.TIME_UNSET if isInitialized() returns false.
The offset is calculated as ntpServerTime - deviceElapsedRealTime.
-
public static void initialize(@Nullable[Loader](../upstream/Loader.html "class in com.google.android.exoplayer2.upstream")loader,
@Nullable[SntpClient.InitializationCallback](SntpClient.InitializationCallback.html "interface in com.google.android.exoplayer2.util")callback)
Deprecated.
Starts loading the device time offset.
Parameters:loader - A Loader to use for loading the time offset, or null to create a new one.callback - An optional SntpClient.InitializationCallback to be notified when the time offset has been initialized or initialization failed.