A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developers.google.com/android/reference/com/google/android/gms/time/TrustedTimeClient below:

TrustedTimeClient | Google Play services

Stay organized with collections Save and categorize content based on your preferences.

public interface TrustedTimeClient

TrustedTimeClient provides access to time signals backed by Google Play Services' accurate time keeping service.

Methods in this class provide time information in various forms:

Application code is expected to retain a reference to this from an Android framework object with an appropriate lifecycle for their needs and call dispose when it is no longer needed. If no reference is retained by application code then listeners registered may cease to trigger due to garbage collection. See dispose for more information.

Summary Public methods
@RequiresApi(api = Build.VERSION_CODES.O)
abstract @Nullable Instant computeCurrentInstant()

Computes the current Instant using the latest time signal from an accurate, external time source, or null if no external time signal is available.

Shortcut to getLatestTimeSignal().computeCurrentInstant().getInstant() with the necessary null checks.

This method is a replacement for Instant.now(), but unlike that method, it cannot be influenced by the device's system clock. This method is suitable for most cases where "current instant" is needed.

See getLatestTimeSignal to obtain the latest time signal that holds error information, and to enable multiple, monotonically increasing instants to be created from the same time signal.

See computeCurrentUnixEpochMillis for an alternative to use on Android release prior to the introduction of the Instant class.

computeCurrentUnixEpochMillis

abstract @Nullable Long computeCurrentUnixEpochMillis()

Computes the number of milliseconds since the start of the Unix epoch from a trusted, external time source, or null if no external time signal is available.

Shortcut to getLatestTimeSignal().computeCurrentInstant().getInstantMillis() with the necessary null checks.

This method is a replacement for System.currentTimeMillis(), but unlike that method, it cannot be influenced by the device's system clock. This method is suitable for most cases where "current instant" is needed.

See getLatestTimeSignal to obtain the latest time signal that holds error information, and to enable multiple, monotonically increasing instants to be created from the same time signal.

This is also equivalent to computeCurrentInstant().toEpochMillis() with null checks but works on Android releases prior to the introduction of the Instant class.

@CanIgnoreReturnValue
abstract Task<Voiddispose()

Disposes of the client after it is no longer needed, deregistering all listeners previously registered against this instance, and freeing internal resources. This should be called before abandoning the client instance to avoid registered listeners pinning application code in memory.

The TrustedTimeClient implementation may automatically dispose when it is garbage collected without an explicit call to dispose, but application code must not assume that it will or it won't.

After dispose has completed, the client instance will throw runtime exceptions for all methods except dispose. TimeSignal and other value types returned / delivered to listeners can continue to be used, with the expected accuracy caveats as they age.

The disposal may be asynchronous. Callers are not required to wait for the returned Task to complete, but the client may continue to operate until the returned Task has completed successfully. For example, listeners may still be informed of time signals after this call returns and until the Task completes.

abstract @Nullable TimeSignal getLatestTimeSignal()

Returns the most recent TimeSignal or null if no external time signal is available.

Different time signals can have different estimated errors, so sequential calls based on different time signals may not be monotonically increasing.

See TimeSignal for how to calculate instants and preserve error information.

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2024-12-10 UTC.

[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-12-10 UTC."],[[["TrustedTimeClient offers access to accurate time data from Google Play Services, providing alternatives to device system clocks."],["It provides time information as Instant, TimeSignal, Ticker, and Ticks, catering to different use cases."],["Applications should retain a reference to TrustedTimeClient and dispose of it when no longer needed to manage resources effectively."],["TrustedTimeClient allows registering and removing listeners for new time signal updates, ensuring applications stay synchronized with accurate time."],["It provides methods for computing the current time as an Instant or Unix epoch milliseconds, useful for various time-based operations."]]],[]]


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4