# MeasureCallback

# MeasureCallback

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/MeasureCallback.kt+class:androidx.health.services.client.MeasureCallback)  
Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/health#1.0.0)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/health/services/client/MeasureCallback "View this page in Java")

<br />

```
interface MeasureCallback
```

<br />

*** ** * ** ***

Callback for[MeasureClient.registerMeasureCallback](https://developer.android.com/reference/kotlin/androidx/health/services/client/MeasureClient#registerMeasureCallback(androidx.health.services.client.data.DeltaDataType,androidx.health.services.client.MeasureCallback)).

## Summary

|                                 ### Public functions                                 |
|--------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)        | [onAvailabilityChanged](https://developer.android.com/reference/kotlin/androidx/health/services/client/MeasureCallback#onAvailabilityChanged(androidx.health.services.client.data.DeltaDataType,androidx.health.services.client.data.Availability))`(` ` dataType: `[DeltaDataType](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/DeltaDataType)`<*, *>,` ` availability: `[Availability](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/Availability) `)` Called when the availability of a[DataType](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/DataType)changes. |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)        | [onDataReceived](https://developer.android.com/reference/kotlin/androidx/health/services/client/MeasureCallback#onDataReceived(androidx.health.services.client.data.DataPointContainer))`(data: `[DataPointContainer](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/DataPointContainer)`)` Called when new data is available.                                                                                                                                                                                                                                                                                                                     |
| `open `[Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [onRegistered](https://developer.android.com/reference/kotlin/androidx/health/services/client/MeasureCallback#onRegistered())`()` Called when this callback has been successfully registered with Health Services.                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| `open `[Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [onRegistrationFailed](https://developer.android.com/reference/kotlin/androidx/health/services/client/MeasureCallback#onRegistrationFailed(kotlin.Throwable))`(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: DeltaDataType<*, *>,
    availability: Availability
): Unit
```

Called when the availability of a[DataType](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/DataType)changes.  

|                                                               Parameters                                                               |
|----------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `dataType: `[DeltaDataType](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/DeltaDataType)`<*, *>` | the[DeltaDataType](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/DeltaDataType)that experienced a change in availability                                                                                                                                                                                                               |
| `availability: `[Availability](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/Availability)       | the new[Availability](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/Availability)status for this[dataType](https://developer.android.com/reference/kotlin/androidx/health/services/client/MeasureCallback#onAvailabilityChanged(androidx.health.services.client.data.DeltaDataType,androidx.health.services.client.data.Availability)) |

### onDataReceived

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

```
fun onDataReceived(data: DataPointContainer): Unit
```

Called when new data is available. Data may be batched.  

|                                                              Parameters                                                              |
|--------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `data: `[DataPointContainer](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/DataPointContainer) | the (potentially batched) set of measured[DataPoint](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/DataPoint)s corresponding to one or more of the requested[DeltaDataType](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/DeltaDataType)s |

### onRegistered

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

```
open 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)  

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

Called when Health Services reports a failure with the registration of this callback. Common causes include: the calling app lacks the necessary permission, or the device does not support the requested[DataType](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/DataType).  

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