@Document(name = "builtin:Stopwatch")
class Stopwatch : Thing


An AppSearch document representing a Stopwatch entity.

A stopwatch is used to count time up, starting from 0, and can be paused and resumed at will.

Summary

Nested types

Builder for Stopwatch.

Constants

const Int

The Stopwatch is paused.

const Int

The Stopwatch is reset.

const Int

The Stopwatch is running.

const Int

The Stopwatch status is unknown

Public functions

Long

Calculates the base time in milliseconds using the currentTimeMillis time base.

Long

Calculates the current accumulated time in milliseconds.

Long

Returns the total duration in milliseconds accumulated by the Stopwatch.

Long

Returns the point in time that the Stopwatch counts up from.

Long

Returns the point in time that the Stopwatch counts up from.

Int

Returns the boot count of the device when this document is last updated.

(Mutable)List<StopwatchLap!>

Returns all the StopwatchLap instances.

Int

Returns the current status.

Inherited functions

From androidx.appsearch.builtintypes.Thing
(Mutable)List<String!>

Returns an unmodifiable list of aliases, if any, for this item.

Long

Returns the creation timestamp, in milliseconds since Unix epoch, of this item.

String?

Returns a description of this item.

Int

Returns the intrinsic score (or importance) of this item.

Long

Returns the time-to-live timestamp, in milliseconds since getCreationTimestampMillis, for this item.

String

Returns the unique identifier for this item.

String?

Returns the URL for an image of this item.

String?

Returns the name of this item.

String

Returns the namespace (or logical grouping) for this item.

(Mutable)List<PotentialAction!>

Returns the actions that can be taken on this object.

String?

Returns the deeplink URL of this item.

Constants

STATUS_PAUSED

Added in 1.1.0-alpha07
const val STATUS_PAUSED = 3: Int

The Stopwatch is paused.

STATUS_RESET

Added in 1.1.0-alpha07
const val STATUS_RESET = 1: Int

The Stopwatch is reset.

STATUS_RUNNING

Added in 1.1.0-alpha07
const val STATUS_RUNNING = 2: Int

The Stopwatch is running.

STATUS_UNKNOWN

Added in 1.1.0-alpha07
const val STATUS_UNKNOWN = 0: Int

The Stopwatch status is unknown

Public functions

calculateBaseTimeMillis

Added in 1.1.0-alpha07
fun calculateBaseTimeMillis(context: Context): Long

Calculates the base time in milliseconds using the currentTimeMillis time base.

If the boot count retrieved from the context matches getBootCount, then getBaseTimeMillisInElapsedRealtime will be used to calculate the base time in the currentTimeMillis time base. Otherwise return getBaseTimeMillis.

calculateCurrentAccumulatedDurationMillis

Added in 1.1.0-alpha07
fun calculateCurrentAccumulatedDurationMillis(context: Context): Long

Calculates the current accumulated time in milliseconds.

Use this method to calculate the accumulated time in real time. Use getAccumulatedDurationMillis to get the static accumulated time stored in the document.

getAccumulatedDurationMillis

Added in 1.1.0-alpha07
fun getAccumulatedDurationMillis(): Long

Returns the total duration in milliseconds accumulated by the Stopwatch.

Use this method to get the static accumulated time stored in the document. Use calculateCurrentAccumulatedDurationMillis to calculate the accumulated time in real time.

getBaseTimeMillis

Added in 1.1.0-alpha07
fun getBaseTimeMillis(): Long

Returns the point in time that the Stopwatch counts up from. In milliseconds using the currentTimeMillis time base.

Use calculateBaseTimeMillis to get a more accurate base time that accounts for the current boot count of the device.

getBaseTimeMillisInElapsedRealtime

Added in 1.1.0-alpha07
fun getBaseTimeMillisInElapsedRealtime(): Long

Returns the point in time that the Stopwatch counts up from. In milliseconds using the elapsedRealtime time base.

ElapsedRealtime should only be used if the getBootCount matches the bootCount of the current device.

getBootCount

Added in 1.1.0-alpha07
fun getBootCount(): Int

Returns the boot count of the device when this document is last updated.

The boot count of the device can be accessed from Global Settings. See BOOT_COUNT.

On older APIs where boot count is not available, this value should not be used.

getLaps

Added in 1.1.0-alpha07
fun getLaps(): (Mutable)List<StopwatchLap!>

Returns all the StopwatchLap instances.

getStatus

Added in 1.1.0-alpha07
fun getStatus(): Int

Returns the current status.

Status can be STATUS_UNKNOWN, STATUS_RESET, STATUS_RUNNING, or STATUS_PAUSED.