# PassiveMonitoringClientExtensionKt

Added in 1.0.0

*** ** * ** ***


```
public final class PassiveMonitoringClientExtensionKt
```

<br />

*** ** * ** ***

## Summary

| ### Public methods |
|---|---|
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Void.html` | `https://developer.android.com/reference/androidx/health/services/client/PassiveMonitoringClientExtensionKt#(androidx.health.services.client.PassiveMonitoringClient).clearPassiveListenerCallback()(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/services/client/PassiveMonitoringClient receiver)` Unregisters the subscription made by `https://developer.android.com/reference/androidx/health/services/client/PassiveMonitoringClient#setPassiveListenerCallback(androidx.health.services.client.data.PassiveListenerConfig,androidx.health.services.client.PassiveListenerCallback)`. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Void.html` | `https://developer.android.com/reference/androidx/health/services/client/PassiveMonitoringClientExtensionKt#(androidx.health.services.client.PassiveMonitoringClient).clearPassiveListenerService()(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/services/client/PassiveMonitoringClient receiver)` Unregisters the subscription made by `https://developer.android.com/reference/androidx/health/services/client/package-summary#(androidx.health.services.client.PassiveMonitoringClient).setPassiveListenerService(java.lang.Class,androidx.health.services.client.data.PassiveListenerConfig)`. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Void.html` | `https://developer.android.com/reference/androidx/health/services/client/PassiveMonitoringClientExtensionKt#(androidx.health.services.client.PassiveMonitoringClient).flush()(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/services/client/PassiveMonitoringClient receiver)` Flushes the sensors for the registered `https://developer.android.com/reference/androidx/health/services/client/data/DataType`s. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/services/client/data/PassiveMonitoringCapabilities` | `https://developer.android.com/reference/androidx/health/services/client/PassiveMonitoringClientExtensionKt#(androidx.health.services.client.PassiveMonitoringClient).getCapabilities()(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/services/client/PassiveMonitoringClient receiver)` Returns the `https://developer.android.com/reference/androidx/health/services/client/data/PassiveMonitoringCapabilities` of this client for this device. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Void.html` | `https://developer.android.com/reference/androidx/health/services/client/PassiveMonitoringClientExtensionKt#(androidx.health.services.client.PassiveMonitoringClient).setPassiveListenerService(java.lang.Class,androidx.health.services.client.data.PassiveListenerConfig)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/services/client/PassiveMonitoringClient receiver, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Class.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/services/client/PassiveListenerService> service, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/services/client/data/PassiveListenerConfig config )` Subscribes for updates to be periodically delivered to the app. |

## Public methods

### clearPassiveListenerCallback

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/PassiveMonitoringClientExtension.kt+function:clearPassiveListenerCallback)

```
public static final @NonNull Void clearPassiveListenerCallback(@NonNull PassiveMonitoringClient receiver)
```

Unregisters the subscription made by `https://developer.android.com/reference/androidx/health/services/client/PassiveMonitoringClient#setPassiveListenerCallback(androidx.health.services.client.data.PassiveListenerConfig,androidx.health.services.client.PassiveListenerCallback)`.

Data will not be delivered after this call so if clients care about any pending batched data they should call flush before unregistering.

| Throws |
|---|---|
| `https://developer.android.com/reference/androidx/health/services/client/HealthServicesException` | if Health Service fails to process the call |

### clearPassiveListenerService

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/PassiveMonitoringClientExtension.kt+function:clearPassiveListenerService)

```
public static final @NonNull Void clearPassiveListenerService(@NonNull PassiveMonitoringClient receiver)
```

Unregisters the subscription made by `https://developer.android.com/reference/androidx/health/services/client/package-summary#(androidx.health.services.client.PassiveMonitoringClient).setPassiveListenerService(java.lang.Class,androidx.health.services.client.data.PassiveListenerConfig)`.

Data will not be delivered after this call so if clients care about any pending batched data they should call flush before unregistering.

| Throws |
|---|---|
| `https://developer.android.com/reference/androidx/health/services/client/HealthServicesException` | if Health Service fails to process the call |

### flush

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/PassiveMonitoringClientExtension.kt+function:flush)

```
public static final @NonNull Void flush(@NonNull PassiveMonitoringClient receiver)
```

Flushes the sensors for the registered `https://developer.android.com/reference/androidx/health/services/client/data/DataType`s.

If no listener 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.

| Throws |
|---|---|
| `https://developer.android.com/reference/androidx/health/services/client/HealthServicesException` | if Health Service fails to process the call |

### getCapabilities

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/PassiveMonitoringClientExtension.kt+function:getCapabilities)

```
public static final @NonNull PassiveMonitoringCapabilities getCapabilities(@NonNull PassiveMonitoringClient receiver)
```

Returns the `https://developer.android.com/reference/androidx/health/services/client/data/PassiveMonitoringCapabilities` of this client for this device.

This can be used to determine what `https://developer.android.com/reference/androidx/health/services/client/data/DataType`s this device supports for passive monitoring and goals. Clients should use the capabilities to inform their requests since Health Services will typically reject requests made for `https://developer.android.com/reference/androidx/health/services/client/data/DataType`s which are not supported.

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/services/client/data/PassiveMonitoringCapabilities` | a `https://developer.android.com/reference/androidx/health/services/client/data/PassiveMonitoringCapabilities` for this device |

| Throws |
|---|---|
| `https://developer.android.com/reference/androidx/health/services/client/HealthServicesException` | if Health Service fails to process the call |

### setPassiveListenerService

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/PassiveMonitoringClientExtension.kt+function:setPassiveListenerService)

```
public static final @NonNull Void setPassiveListenerService(
    @NonNull PassiveMonitoringClient receiver,
    @NonNull Class<@NonNull PassiveListenerService> service,
    @NonNull PassiveListenerConfig config
)
```

Subscribes for updates to be periodically delivered to the app.

Data updates will be batched and delivered from the point of initial registration and will continue to be delivered until the `https://developer.android.com/reference/androidx/health/services/client/data/DataType` is unregistered, either by explicitly calling `https://developer.android.com/reference/androidx/health/services/client/package-summary#(androidx.health.services.client.PassiveMonitoringClient).clearPassiveListenerService()` or by registering again without that `https://developer.android.com/reference/androidx/health/services/client/data/DataType` included in the request. Higher frequency updates are available through `https://developer.android.com/reference/androidx/health/services/client/ExerciseClient` or `https://developer.android.com/reference/androidx/health/services/client/MeasureClient`. Any requested goal, user activity, or health event updates will not be batched.

Health Services will automatically bind to the provided `https://developer.android.com/reference/androidx/health/services/client/PassiveListenerService` to send the update. Clients are responsible for defining the service in their app manifest. They should also require the `com.google.android.wearable.healthservices.permission.PASSIVE_DATA_BINDING` permission in their app manifest service definition in order to ensure that Health Services is the source of the binding.

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 `https://developer.android.com/reference/androidx/health/services/client/data/PassiveListenerConfig` is supported on this device by checking the `https://developer.android.com/reference/androidx/health/services/client/data/PassiveMonitoringCapabilities`. The returned future will fail if the request is not supported on the current device or the client does not have the required permissions for the request.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Class.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/services/client/PassiveListenerService> service` | the `https://developer.android.com/reference/androidx/health/services/client/PassiveListenerService` to bind to |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/services/client/data/PassiveListenerConfig config` | the `https://developer.android.com/reference/androidx/health/services/client/data/PassiveListenerConfig` from the client |

| Throws |
|---|---|
| `https://developer.android.com/reference/androidx/health/services/client/HealthServicesException` | if Health Service fails to process the call |
| `https://developer.android.com/reference/java/lang/SecurityException.html` | if calling app does not have the required permissions |