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 events, 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>
registerDataCallback(
    @NonNull Set<@NonNull DataType> dataTypes,
    @NonNull PendingIntent callbackIntent
)

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

abstract @NonNull ListenableFuture<@NonNull Void>
registerDataCallback(
    @NonNull Set<@NonNull DataType> dataTypes,
    @NonNull PendingIntent callbackIntent,
    @NonNull PassiveMonitoringCallback callback
)

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>
registerEventCallback(
    @NonNull Event event,
    @NonNull PendingIntent callbackIntent
)

Registers for notification of the event 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 Event.

Public fields

capabilities

@NonNull
public abstract @NonNull ListenableFuture<@NonNull PassiveMonitoringCapabilitiescapabilities

Returns the PassiveMonitoringCapabilities of this client for the device.

Public methods

registerDataCallback

@NonNull
public abstract ListenableFuture<@NonNull VoidregisterDataCallback(
    @NonNull Set<@NonNull DataType> dataTypes,
    @NonNull PendingIntent callbackIntent
)

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 provided PendingIntent will be invoked periodically with the collected data.

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

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

registerDataCallback

@NonNull
public abstract ListenableFuture<@NonNull VoidregisterDataCallback(
    @NonNull Set<@NonNull DataType> dataTypes,
    @NonNull PendingIntent callbackIntent,
    @NonNull 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 to the callbackIntent.

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

registerEventCallback

@NonNull
public abstract ListenableFuture<@NonNull VoidregisterEventCallback(
    @NonNull Event event,
    @NonNull PendingIntent callbackIntent
)

Registers for notification of the event being triggered.

The provided PendingIntent will be sent whenever event is triggered.

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

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

unregisterDataCallback

@NonNull
public abstract ListenableFuture<@NonNull VoidunregisterDataCallback()

Unregisters the subscription made by PassiveMonitoringClient.registerDataCallback.

The associated PendingIntent will be called one last time with any remaining buffered data.

unregisterEventCallback

@NonNull
public abstract ListenableFuture<@NonNull VoidunregisterEventCallback(@NonNull Event event)

Unregisters the subscription for the given Event.