ExerciseUpdateCallback

public interface ExerciseUpdateCallback


Callback that is called when the state of the current exercise is updated.

Summary

Public methods

abstract void
onAvailabilityChanged(
    @NonNull DataType<@NonNull ?, @NonNull ?> dataType,
    @NonNull Availability availability
)

Called during an ExerciseState.ACTIVE exercise when the availability of a DataType changes.

default void

Called when an ExerciseEvent is emitted.

abstract void

Called during an ACTIVE exercise or on any changes in ExerciseState.

abstract void

Called during an ExerciseState.ACTIVE exercise once a lap has been marked.

abstract void

Called when this callback has been successfully registered with Health Services.

abstract void

Called when Health Services reports a failure with the registration of this callback.

Public methods

onAvailabilityChanged

Added in 1.0.0
abstract void onAvailabilityChanged(
    @NonNull DataType<@NonNull ?, @NonNull ?> dataType,
    @NonNull Availability availability
)

Called during an ExerciseState.ACTIVE exercise when the availability of a DataType changes.

Parameters
@NonNull DataType<@NonNull ?, @NonNull ?> dataType

the DataType which experienced a change in availability

@NonNull Availability availability

the new Availability state

onExerciseEventReceived

Added in 1.1.0-alpha02
default void onExerciseEventReceived(@NonNull ExerciseEvent event)

Called when an ExerciseEvent is emitted. May be called during any exercise state except for PREPARING or ENDED.

Parameters
@NonNull ExerciseEvent event

the latest ExerciseEvent received during an active exercise. To access the data for each received ExerciseEvent, clients can use conditional when on ExerciseEvent for a specific event type to access the event-specific data.

onExerciseUpdateReceived

Added in 1.0.0
abstract void onExerciseUpdateReceived(@NonNull ExerciseUpdate update)

Called during an ACTIVE exercise or on any changes in ExerciseState.

Parameters
@NonNull ExerciseUpdate update

the ExerciseUpdate containing the latest exercise information

onLapSummaryReceived

Added in 1.0.0
abstract void onLapSummaryReceived(@NonNull ExerciseLapSummary lapSummary)

Called during an ExerciseState.ACTIVE exercise once a lap has been marked.

Parameters
@NonNull ExerciseLapSummary lapSummary

an ExerciseLapSummary containing a summary of data collected during the past lap

onRegistered

Added in 1.0.0
abstract void onRegistered()

Called when this callback has been successfully registered with Health Services.

onRegistrationFailed

Added in 1.0.0
abstract void onRegistrationFailed(@NonNull Throwable throwable)

Called when Health Services reports a failure with the registration of this callback.

Parameters
@NonNull Throwable throwable

a throwable sent by Health Services with information about the failure