ExerciseUpdate

public final class ExerciseUpdate


Contains the latest updated state and metrics for the current exercise.

Summary

Nested types

This records the last time the exercise transitioned from an active to an inactive state or from an inactive to an active state, where inactive states match those found in ExerciseState.isPaused or ExerciseState.isEnded.

Public methods

boolean
equals(Object other)
final @NonNull Duration

Returns the ActiveDuration of the exercise at the time of the provided IntervalDataPoint.

final @NonNull Duration

Returns the ActiveDuration of the exercise at the time of the provided SampleDataPoint.

final ExerciseUpdate.ActiveDurationCheckpoint

Returns the ActiveDurationCheckpoint which can be used to determine the active duration of the exercise in a way that is consistent with Health Services.

final ExerciseConfig

Returns the ExerciseConfig used by the exercise when the ExerciseUpdate was dispatched and returns null if the exercise is in prepare phase and hasn't been started yet.

final @NonNull ExerciseStateInfo

Returns the ExerciseStateInfo containing the current ExerciseState and ExerciseEndReason, if applicable.

final @NonNull Set<@NonNull ExerciseGoal<@NonNull Number>>

Returns the latest ExerciseGoalType.ONE_TIME_GOALs that have been achieved.

final @NonNull DataPointContainer

Returns the list of the latest DataPoints.

final @NonNull Set<@NonNull MilestoneMarkerSummary>

Returns the latest MilestoneMarkerSummarys.

final Instant

Returns the time at which the exercise was started or null if the exercise is in prepare phase and hasn't started yet.

final @NonNull Duration

Returns the duration since boot when this ExerciseUpdate was created.

int
@NonNull String

Public methods

equals

public boolean equals(Object other)

getActiveDurationAtDataPoint

Added in 1.0.0
public final @NonNull Duration getActiveDurationAtDataPoint(
    @NonNull IntervalDataPoint<@NonNull ?> dataPoint
)

Returns the ActiveDuration of the exercise at the time of the provided IntervalDataPoint. The provided IntervalDataPoint should be present in this ExerciseUpdate.

Throws
kotlin.IllegalArgumentException

if dataPoint is not present in this ExerciseUpdate

kotlin.IllegalStateException

if this ExerciseUpdate does not contain a valid updateDurationFromBoot which may happen if the Health Services app is out of date

getActiveDurationAtDataPoint

Added in 1.0.0
public final @NonNull Duration getActiveDurationAtDataPoint(
    @NonNull SampleDataPoint<@NonNull ?> dataPoint
)

Returns the ActiveDuration of the exercise at the time of the provided SampleDataPoint. The provided SampleDataPoint should be present in this ExerciseUpdate.

Throws
kotlin.IllegalArgumentException

if dataPoint is not present in this ExerciseUpdate

getActiveDurationCheckpoint

Added in 1.0.0
public final ExerciseUpdate.ActiveDurationCheckpoint getActiveDurationCheckpoint()

Returns the ActiveDurationCheckpoint which can be used to determine the active duration of the exercise in a way that is consistent with Health Services. Clients can anchor their application timers against this to ensure their view of the active duration matches the view of Health Services.

getExerciseConfig

Added in 1.0.0
public final ExerciseConfig getExerciseConfig()

Returns the ExerciseConfig used by the exercise when the ExerciseUpdate was dispatched and returns null if the exercise is in prepare phase and hasn't been started yet.

getExerciseStateInfo

Added in 1.0.0
public final @NonNull ExerciseStateInfo getExerciseStateInfo()

Returns the ExerciseStateInfo containing the current ExerciseState and ExerciseEndReason, if applicable.

getLatestAchievedGoals

Added in 1.0.0
public final @NonNull Set<@NonNull ExerciseGoal<@NonNull Number>> getLatestAchievedGoals()

Returns the latest ExerciseGoalType.ONE_TIME_GOALs that have been achieved. ExerciseGoalType.MILESTONEs will be returned via latestMilestoneMarkerSummaries.

getLatestMetrics

Added in 1.0.0
public final @NonNull DataPointContainer getLatestMetrics()

Returns the list of the latest DataPoints.

getLatestMilestoneMarkerSummaries

Added in 1.0.0
public final @NonNull Set<@NonNull MilestoneMarkerSummarygetLatestMilestoneMarkerSummaries()

Returns the latest MilestoneMarkerSummarys.

getStartTime

Added in 1.0.0
public final Instant getStartTime()

Returns the time at which the exercise was started or null if the exercise is in prepare phase and hasn't started yet.

getUpdateDurationFromBoot

Added in 1.0.0
public final @NonNull Duration getUpdateDurationFromBoot()

Returns the duration since boot when this ExerciseUpdate was created.

Throws
kotlin.IllegalStateException

if this ExerciseUpdate does not contain a valid updateDurationFromBoot which may happen if the Health Services app is out of date

hashCode

public int hashCode()

toString

public @NonNull String toString()