# ExerciseUpdateCallback

Artifact: [androidx.health:health-services-client](https://developer.android.com/jetpack/androidx/releases/health) [View Source](https://cs.android.com/search?q=file:androidx/health/services/client/ExerciseUpdateCallback.kt+class:androidx.health.services.client.ExerciseUpdateCallback) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/health#1.0.0)

*** ** * ** ***


```
interface ExerciseUpdateCallback
```

<br />

*** ** * ** ***

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

## Summary

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/health/services/client/ExerciseUpdateCallback#onAvailabilityChanged(androidx.health.services.client.data.DataType,androidx.health.services.client.data.Availability)( dataType: https://developer.android.com/reference/kotlin/androidx/health/services/client/data/DataType<*, *>, availability: https://developer.android.com/reference/kotlin/androidx/health/services/client/data/Availability )` Called during an `https://developer.android.com/reference/kotlin/androidx/health/services/client/data/ExerciseState#ACTIVE()` exercise when the availability of a `https://developer.android.com/reference/kotlin/androidx/health/services/client/data/DataType` changes. |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/health/services/client/ExerciseUpdateCallback#onExerciseEventReceived(androidx.health.services.client.data.ExerciseEvent)(event: https://developer.android.com/reference/kotlin/androidx/health/services/client/data/ExerciseEvent)` Called when an `https://developer.android.com/reference/kotlin/androidx/health/services/client/data/ExerciseEvent` is emitted. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/health/services/client/ExerciseUpdateCallback#onExerciseUpdateReceived(androidx.health.services.client.data.ExerciseUpdate)(update: https://developer.android.com/reference/kotlin/androidx/health/services/client/data/ExerciseUpdate)` Called during an ACTIVE exercise or on any changes in `https://developer.android.com/reference/kotlin/androidx/health/services/client/data/ExerciseState`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/health/services/client/ExerciseUpdateCallback#onLapSummaryReceived(androidx.health.services.client.data.ExerciseLapSummary)(lapSummary: https://developer.android.com/reference/kotlin/androidx/health/services/client/data/ExerciseLapSummary)` Called during an `https://developer.android.com/reference/kotlin/androidx/health/services/client/data/ExerciseState#ACTIVE()` exercise once a lap has been marked. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/health/services/client/ExerciseUpdateCallback#onRegistered()()` Called when this callback has been successfully registered with Health Services. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/health/services/client/ExerciseUpdateCallback#onRegistrationFailed(kotlin.Throwable)(throwable: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-throwable/index.html)` Called when Health Services reports a failure with the registration of this callback. |

## Public functions

### onAvailabilityChanged

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/health#1.0.0)

```
fun onAvailabilityChanged(
    dataType: DataType<*, *>,
    availability: Availability
): Unit
```

Called during an `https://developer.android.com/reference/kotlin/androidx/health/services/client/data/ExerciseState#ACTIVE()` exercise when the availability of a `https://developer.android.com/reference/kotlin/androidx/health/services/client/data/DataType` changes.

| Parameters |
|---|---|
| `dataType: https://developer.android.com/reference/kotlin/androidx/health/services/client/data/DataType<*, *>` | the `https://developer.android.com/reference/kotlin/androidx/health/services/client/data/DataType` which experienced a change in availability |
| `availability: https://developer.android.com/reference/kotlin/androidx/health/services/client/data/Availability` | the new `https://developer.android.com/reference/kotlin/androidx/health/services/client/data/Availability` state |

### onExerciseEventReceived

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/health#1.1.0)

```
open fun onExerciseEventReceived(event: ExerciseEvent): Unit
```

Called when an `https://developer.android.com/reference/kotlin/androidx/health/services/client/data/ExerciseEvent` is emitted. May be called during any exercise state except for PREPARING or ENDED.

| Parameters |
|---|---|
| `event: https://developer.android.com/reference/kotlin/androidx/health/services/client/data/ExerciseEvent` | the latest `https://developer.android.com/reference/kotlin/androidx/health/services/client/data/ExerciseEvent` received during an active exercise. To access the data for each received `https://developer.android.com/reference/kotlin/androidx/health/services/client/data/ExerciseEvent`, clients can use conditional `when` on `https://developer.android.com/reference/kotlin/androidx/health/services/client/data/ExerciseEvent` for a specific event type to access the event-specific data. |

### onExerciseUpdateReceived

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/health#1.0.0)

```
fun onExerciseUpdateReceived(update: ExerciseUpdate): Unit
```

Called during an ACTIVE exercise or on any changes in `https://developer.android.com/reference/kotlin/androidx/health/services/client/data/ExerciseState`.

| Parameters |
|---|---|
| `update: https://developer.android.com/reference/kotlin/androidx/health/services/client/data/ExerciseUpdate` | the `https://developer.android.com/reference/kotlin/androidx/health/services/client/data/ExerciseUpdate` containing the latest exercise information |

### onLapSummaryReceived

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/health#1.0.0)

```
fun onLapSummaryReceived(lapSummary: ExerciseLapSummary): Unit
```

Called during an `https://developer.android.com/reference/kotlin/androidx/health/services/client/data/ExerciseState#ACTIVE()` exercise once a lap has been marked.

| Parameters |
|---|---|
| `lapSummary: https://developer.android.com/reference/kotlin/androidx/health/services/client/data/ExerciseLapSummary` | an `https://developer.android.com/reference/kotlin/androidx/health/services/client/data/ExerciseLapSummary` containing a summary of data collected during the past lap |

### onRegistered

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/health#1.0.0)

```
fun onRegistered(): Unit
```

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

### onRegistrationFailed

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/health#1.0.0)

```
fun onRegistrationFailed(throwable: Throwable): Unit
```

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

| Parameters |
|---|---|
| `throwable: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-throwable/index.html` | a throwable sent by Health Services with information about the failure |