ServiceBackedMeasureClient

class ServiceBackedMeasureClient : MeasureClient
kotlin.Any
   ↳ androidx.health.services.client.impl.ServiceBackedMeasureClient

MeasureClient implementation that is backed by Health Services.

Summary

Public constructors
ServiceBackedMeasureClient(context: Context, connectionManager: ConnectionManager)

MeasureClient implementation that is backed by Health Services.

Public methods
ListenableFuture<Void>
registerCallback(dataType: DataType, callback: MeasureCallback)

Registers the app for live measurement of the specified DataType.

ListenableFuture<Void>
registerCallback(dataType: DataType, callback: MeasureCallback, executor: Executor)

Same as registerCallback, except the callback is called on the given Executor.

ListenableFuture<Void>

Unregisters the given MeasureCallback for updates of the given DataType.

Properties
ListenableFuture<MeasureCapabilities>

Returns the MeasureCapabilities of this client for the device.

Public constructors

ServiceBackedMeasureClient

ServiceBackedMeasureClient(
    context: Context,
    connectionManager: ConnectionManager)

MeasureClient implementation that is backed by Health Services.

Public methods

registerCallback

fun registerCallback(
    dataType: DataType,
    callback: MeasureCallback
): ListenableFuture<Void>

Registers the app for live measurement of the specified DataType.

The callback will be called on the main application thread. To move calls to an alternative thread use registerCallback.

Even if data is registered for live capture, it can still be sent out in batches depending on the application processor state.

Registering a DataType for live measurement capture is expected to increase the sample rate on the associated sensor(s); this is typically used for one-off measurements. Do not use this method for background capture or workout tracking.

The callback will continue to be called until the app is killed or unregisterCallback is called.

If the same callback is already registered for the given DataType, this operation is a no-op.

registerCallback

fun registerCallback(
    dataType: DataType,
    callback: MeasureCallback,
    executor: Executor
): ListenableFuture<Void>

Same as registerCallback, except the callback is called on the given Executor.

unregisterCallback

fun unregisterCallback(
    dataType: DataType,
    callback: MeasureCallback
): ListenableFuture<Void>

Unregisters the given MeasureCallback for updates of the given DataType.

Properties

capabilities

val capabilities: ListenableFuture<MeasureCapabilities>

Returns the MeasureCapabilities of this client for the device.