# DefaultTileClient

Artifact: [androidx.wear.tiles:tiles-renderer](https://developer.android.com/jetpack/androidx/releases/wear-tiles) [View Source](https://cs.android.com/search?q=file:androidx/wear/tiles/connection/DefaultTileClient.kt+class:androidx.wear.tiles.connection.DefaultTileClient) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/wear-tiles#1.0.0)

*** ** * ** ***

<br />

```
public final class DefaultTileClient implements TileClient
```

<br />

*** ** * ** ***

Implementation of `https://developer.android.com/reference/androidx/wear/tiles/client/TileClient` which can connect to a `TileService` in either the local process, or in a remote app.

This implementation will only stay connected for as long as required. Each call will cause this client to connect to the `TileService`, and call the specified remote method. It will then disconnect again after one second of inactivity (so calls in quick succession will share the same binder).

Note that there is a timeout of 10s when connecting to the `TileService`, and a timeout of 30s for `https://developer.android.com/reference/androidx/wear/tiles/connection/DefaultTileClient#requestTile(androidx.wear.tiles.RequestBuilders.TileRequest)` and `https://developer.android.com/reference/androidx/wear/tiles/connection/DefaultTileClient#requestResources(androidx.wear.tiles.RequestBuilders.ResourcesRequest)` to return a payload.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/wear/tiles/connection/DefaultTileClient#DefaultTileClient(android.content.Context,android.content.ComponentName,java.util.concurrent.Executor)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/Context.html context, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/ComponentName.html componentName, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/concurrent/Executor.html executor )` Build an instance of `https://developer.android.com/reference/androidx/wear/tiles/connection/DefaultTileClient` for use with a given `https://developer.android.com/reference/java/util/concurrent/Executor.html`. |
| `https://developer.android.com/reference/androidx/wear/tiles/connection/DefaultTileClient#DefaultTileClient(android.content.Context,android.content.ComponentName,kotlinx.coroutines.CoroutineScope,kotlinx.coroutines.CoroutineDispatcher)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/Context.html context, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/ComponentName.html componentName, @https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-scope/index.html coroutineScope, @https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-dispatcher/index.html coroutineDispatcher )` Build an instance of `https://developer.android.com/reference/androidx/wear/tiles/connection/DefaultTileClient` for use with a coroutine dispatcher. |

| ### Public methods |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Integer.html>` | `https://developer.android.com/reference/androidx/wear/tiles/connection/DefaultTileClient#requestApiVersion()()` Gets the API version supported by the connected TileService. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/tiles/ResourceBuilders.Resources>` | `[requestResources](https://developer.android.com/reference/androidx/wear/tiles/connection/DefaultTileClient#requestResources(androidx.wear.tiles.RequestBuilders.ResourcesRequest))( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/tiles/RequestBuilders.ResourcesRequest requestParams )` **This method is deprecated.** Use `https://developer.android.com/reference/androidx/wear/tiles/client/TileClient#requestTileResourcesAsync(androidx.wear.tiles.RequestBuilders.ResourcesRequest)` instead. <br /> |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/tiles/TileBuilders.Tile>` | `https://developer.android.com/reference/androidx/wear/tiles/connection/DefaultTileClient#requestTile(androidx.wear.tiles.RequestBuilders.TileRequest)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/tiles/RequestBuilders.TileRequest requestParams)` Request a tile payload from the connected TileService. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/ResourceBuilders.Resources>` | `https://developer.android.com/reference/androidx/wear/tiles/connection/DefaultTileClient#requestTileResourcesAsync(androidx.wear.tiles.RequestBuilders.ResourcesRequest)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/tiles/RequestBuilders.ResourcesRequest requestParams )` Request a resource bundle from the connected TileService. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://developer.android.com/reference/java/lang/Void.html>` | `https://developer.android.com/reference/androidx/wear/tiles/connection/DefaultTileClient#sendOnTileAddedEvent()()` Send a Tile Added notification to the connected TileService. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://developer.android.com/reference/java/lang/Void.html>` | `https://developer.android.com/reference/androidx/wear/tiles/connection/DefaultTileClient#sendOnTileEnterEvent()()` Send a Tile Enter notification to the connected TileService. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://developer.android.com/reference/java/lang/Void.html>` | `https://developer.android.com/reference/androidx/wear/tiles/connection/DefaultTileClient#sendOnTileLeaveEvent()()` Send a Tile Leave notification to the connected TileService. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://developer.android.com/reference/java/lang/Void.html>` | `https://developer.android.com/reference/androidx/wear/tiles/connection/DefaultTileClient#sendOnTileRemovedEvent()()` Send a Tile Removed notification to the connected TileService. |

## Public constructors

### DefaultTileClient

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

```
public DefaultTileClient(
    @NonNull Context context,
    @NonNull ComponentName componentName,
    @NonNull Executor executor
)
```

Build an instance of `https://developer.android.com/reference/androidx/wear/tiles/connection/DefaultTileClient` for use with a given `https://developer.android.com/reference/java/util/concurrent/Executor.html`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/Context.html context` | The application context to use when binding to the `https://developer.android.com/reference/androidx/wear/tiles/TileService`. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/ComponentName.html componentName` | The `https://developer.android.com/reference/android/content/ComponentName.html` of the `https://developer.android.com/reference/androidx/wear/tiles/TileService` to bind to. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/concurrent/Executor.html executor` | An `https://developer.android.com/reference/java/util/concurrent/Executor.html` to use when dispatching calls to the `https://developer.android.com/reference/androidx/wear/tiles/TileService`. |

### DefaultTileClient

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

```
public DefaultTileClient(
    @NonNull Context context,
    @NonNull ComponentName componentName,
    @NonNull CoroutineScope coroutineScope,
    @NonNull CoroutineDispatcher coroutineDispatcher
)
```

Build an instance of `https://developer.android.com/reference/androidx/wear/tiles/connection/DefaultTileClient` for use with a coroutine dispatcher.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/Context.html context` | The application context to use when binding to the `https://developer.android.com/reference/androidx/wear/tiles/TileService`. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/ComponentName.html componentName` | The `https://developer.android.com/reference/android/content/ComponentName.html` of the `https://developer.android.com/reference/androidx/wear/tiles/TileService` to bind to. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-scope/index.html coroutineScope` | A `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-scope/index.html` to use when dispatching calls to the `https://developer.android.com/reference/androidx/wear/tiles/TileService`. Cancelling the passed `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-scope/index.html` will also cancel any pending work in this class. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-dispatcher/index.html coroutineDispatcher` | A `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-dispatcher/index.html` to use when dispatching work from this class. |

## Public methods

### requestApiVersion

```
public @NonNull ListenableFuture<@NonNull Integer> requestApiVersion()
```

Gets the API version supported by the connected TileService.

### requestResources

```
public @NonNull ListenableFuture<@NonNull ResourceBuilders.Resources> [requestResources](https://developer.android.com/reference/androidx/wear/tiles/connection/DefaultTileClient#requestResources(androidx.wear.tiles.RequestBuilders.ResourcesRequest))(
    @NonNull RequestBuilders.ResourcesRequest requestParams
)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/androidx/wear/tiles/client/TileClient#requestTileResourcesAsync(androidx.wear.tiles.RequestBuilders.ResourcesRequest)` instead.

Request a resource bundle from the connected TileService.

### requestTile

```
public @NonNull ListenableFuture<@NonNull TileBuilders.Tile> requestTile(@NonNull RequestBuilders.TileRequest requestParams)
```

Request a tile payload from the connected TileService.

### requestTileResourcesAsync

```
public @NonNull ListenableFuture<@NonNull ResourceBuilders.Resources> requestTileResourcesAsync(
    @NonNull RequestBuilders.ResourcesRequest requestParams
)
```

Request a resource bundle from the connected TileService.

### sendOnTileAddedEvent

```
public @NonNull ListenableFuture<Void> sendOnTileAddedEvent()
```

Send a Tile Added notification to the connected TileService.

### sendOnTileEnterEvent

```
public @NonNull ListenableFuture<Void> sendOnTileEnterEvent()
```

Send a Tile Enter notification to the connected TileService.

### sendOnTileLeaveEvent

```
public @NonNull ListenableFuture<Void> sendOnTileLeaveEvent()
```

Send a Tile Leave notification to the connected TileService.

### sendOnTileRemovedEvent

```
public @NonNull ListenableFuture<Void> sendOnTileRemovedEvent()
```

Send a Tile Removed notification to the connected TileService.