PassiveMonitoringClient

interface PassiveMonitoringClient


Client which provides a means to passively monitor data without requiring an ongoing workout.

The lifetimes of registrations made through this client are independent of the lifetime of the subscribing app. These registrations are therefore suitable for notifying of ongoing measurements or triggered passive goals, regardless of whether or not the subscribing app is currently running, in the foreground or engaged in a workout.

Summary

Public fields

abstract @NonNull ListenableFuture<@NonNull PassiveMonitoringCapabilities>

Returns the PassiveMonitoringCapabilities of this client for the device.

Public methods

abstract @NonNull ListenableFuture<@NonNull Void>

Flushes the sensors for the registered DataTypes.

abstract @NonNull ListenableFuture<@NonNull Void>

Subscribes for updates on a set of data types to be periodically delivered to the app.

abstract @NonNull ListenableFuture<@NonNull Void>

Subscribes an intent callback (the same way as PassiveMonitoringClient.registerDataCallback ) and a PassiveMonitoringCallback for updates on a set of data types periodically.

abstract @NonNull ListenableFuture<@NonNull Void>
registerPassiveGoalCallback(
    PassiveGoal passiveGoal,
    ComponentName componentName
)

Registers for notification of the passiveGoal being triggered.

abstract @NonNull ListenableFuture<@NonNull Void>

Unregisters the subscription made by PassiveMonitoringClient.registerDataCallback.

abstract @NonNull ListenableFuture<@NonNull Void>

Unregisters the subscription for the given PassiveGoal.

Public fields

capabilities

abstract @NonNull ListenableFuture<@NonNull PassiveMonitoringCapabilitiescapabilities

Returns the PassiveMonitoringCapabilities of this client for the device.

Public methods

flush

abstract @NonNull ListenableFuture<@NonNull Voidflush()

Flushes the sensors for the registered DataTypes.

If no intent has been registered by this client, this will be a no-op. This call should be used sparingly and will be subject to throttling by Health Services.

registerDataCallback

abstract @NonNull ListenableFuture<@NonNull VoidregisterDataCallback(PassiveMonitoringConfig configuration)

Subscribes for updates on a set of data types to be periodically delivered to the app.

Data will be batched. Higher frequency updates are available through ExerciseClient or MeasureClient.

The data will be broadcast to the provided ComponentName periodically to the action: PassiveMonitoringUpdate.INTENT_DATA_ACTION. A PassiveMonitoringUpdate can be extracted from the intent using PassiveMonitoringUpdate.fromIntent.

Subscribing apps are responsible for ensuring they can receive the intent by e.g. declaring a suitable BroadcastReceiver in their app manifest.

This registration is unique per subscribing app. Subsequent registrations will replace the previous registration, if one had been made. The client is responsible for ensuring that their requested PassiveMonitoringConfig is supported on this device by checking the PassiveMonitoringCapabilities. The returned future will fail if the request is not supported on a given device.

registerDataCallback

abstract @NonNull ListenableFuture<@NonNull VoidregisterDataCallback(
    PassiveMonitoringConfig configuration,
    PassiveMonitoringCallback callback
)

Subscribes an intent callback (the same way as PassiveMonitoringClient.registerDataCallback ) and a PassiveMonitoringCallback for updates on a set of data types periodically.

The provided callback will take priority in receiving updates as long the app is alive and the callback can be successfully notified. Otherwise, updates will be delivered via Intent to the componentName with the provided actionName.

This registration is unique per subscribing app. Subsequent registrations will replace the previous registration, if one had been made.

registerPassiveGoalCallback

abstract @NonNull ListenableFuture<@NonNull VoidregisterPassiveGoalCallback(
    PassiveGoal passiveGoal,
    ComponentName componentName
)

Registers for notification of the passiveGoal being triggered.

An Intent will be broadcast to the provided ComponentName with the action PassiveMonitoringUpdate.INTENT_GOAL_ACTION whenever the passiveGoal is triggered.

Subscribing apps are responsible for ensuring they can receive the intent by e.g. declaring a suitable BroadcastReceiver in their app manifest.

Registration of multiple passive goals is possible except where there already exists an passive goal that is equal, as per the definition of PassiveGoal.equals, in which case the existing registration for that passive goal will be replaced.

unregisterDataCallback

abstract @NonNull ListenableFuture<@NonNull VoidunregisterDataCallback()

Unregisters the subscription made by PassiveMonitoringClient.registerDataCallback.

The Intent will be broadcast to the ComponentName one last time with any remaining buffered data.

unregisterPassiveGoalCallback

abstract @NonNull ListenableFuture<@NonNull VoidunregisterPassiveGoalC