# PlatformDataProvider

Artifact: [androidx.wear.protolayout:protolayout-expression-pipeline](https://developer.android.com/jetpack/androidx/releases/wear-protolayout) [View Source](https://cs.android.com/search?q=file:androidx/wear/protolayout/expression/pipeline/PlatformDataProvider.java+class:androidx.wear.protolayout.expression.pipeline.PlatformDataProvider) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.0.0)

*** ** * ** ***


```
public interface PlatformDataProvider
```

<br />

*** ** * ** ***

This interface is used by platform data providers to yield dynamic data for their supported data keys.

It's up to the implementations to check if the expression provider has the required permission before sending data with `https://developer.android.com/reference/androidx/wear/protolayout/expression/pipeline/PlatformDataReceiver#onData(androidx.wear.protolayout.expression.PlatformDataValues)`. If a required permission is not granted or is revoked they should stop sending more data and call `https://developer.android.com/reference/androidx/wear/protolayout/expression/pipeline/PlatformDataReceiver#onInvalidated(java.util.Set<androidx.wear.protolayout.expression.PlatformDataKey<?>>)` instead.

## Summary

| ### Public methods |
|---|---|
| `abstract void` | `https://developer.android.com/reference/androidx/wear/protolayout/expression/pipeline/PlatformDataProvider#clearReceiver()()` Clears the receiver from the provider. |
| `abstract void` | `https://developer.android.com/reference/androidx/wear/protolayout/expression/pipeline/PlatformDataProvider#setReceiver(java.util.concurrent.Executor,androidx.wear.protolayout.expression.pipeline.PlatformDataReceiver)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/concurrent/Executor.html executor, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/protolayout/expression/pipeline/PlatformDataReceiver receiver )` Sets the receiver for receiving the platform data from this provider. |

## Public methods

### clearReceiver

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

```
abstract void clearReceiver()
```

Clears the receiver from the provider.

### setReceiver

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

```
abstract void setReceiver(
    @NonNull Executor executor,
    @NonNull PlatformDataReceiver receiver
)
```

Sets the receiver for receiving the platform data from this provider.

Calling this method while there is already a receiver set, should replace the previous receiver.

The implementation should periodically send the dynamic data values for the set of `https://developer.android.com/reference/androidx/wear/protolayout/expression/PlatformDataKey`s specified when registering this `https://developer.android.com/reference/androidx/wear/protolayout/expression/pipeline/PlatformDataProvider` in `https://developer.android.com/reference/androidx/wear/protolayout/expression/pipeline/DynamicTypeEvaluator.Config.Builder#addPlatformDataProvider(androidx.wear.protolayout.expression.pipeline.PlatformDataProvider,java.util.Set<androidx.wear.protolayout.expression.PlatformDataKey<?>>)`

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/protolayout/expression/pipeline/PlatformDataReceiver receiver` | The `https://developer.android.com/reference/androidx/wear/protolayout/expression/pipeline/PlatformDataReceiver` to receive the new dynamic values or to be notified that the current data has been invalidated for the registered keys. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/concurrent/Executor.html executor` | The executor to run the `https://developer.android.com/reference/androidx/wear/protolayout/expression/pipeline/PlatformDataReceiver#onData(androidx.wear.protolayout.expression.PlatformDataValues)` or `https://developer.android.com/reference/androidx/wear/protolayout/expression/pipeline/PlatformDataReceiver#onInvalidated(java.util.Set<androidx.wear.protolayout.expression.PlatformDataKey<?>>)` on. |