# TileKt

Added in 1.6.2

*** ** * ** ***


```
public final class TileKt
```

<br />

*** ** * ** ***

## Summary

| ### Public methods |
|---|---|
| `static final @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/TileKt#tile(androidx.wear.protolayout.TimelineBuilders.Timeline,kotlin.time.Duration,androidx.wear.protolayout.StateBuilders.State,kotlin.String)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/TimelineBuilders.Timeline timeline, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.time/-duration/index.html freshness, @https://developer.android.com/reference/androidx/wear/protolayout/expression/RequiresSchemaVersion(major = 1, minor = 200) https://developer.android.com/reference/androidx/wear/protolayout/StateBuilders.State state, https://developer.android.com/reference/java/lang/String.html resourcesVersion )` Creates a tile from the defined parameters and layout components defined in the `https://developer.android.com/reference/androidx/wear/protolayout/TimelineBuilders.Timeline` that can be rendered by a tile renderer. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/TimelineBuilders.TimeInterval` | `https://developer.android.com/reference/androidx/wear/tiles/TileKt#timeInterval(kotlin.time.Duration,kotlin.time.Duration)(@https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.time/-duration/index.html start, @https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.time/-duration/index.html end)` Creates a time interval, typically used to describe the validity period of a `https://developer.android.com/reference/androidx/wear/protolayout/TimelineBuilders.TimelineEntry`. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/TimelineBuilders.Timeline` | `https://developer.android.com/reference/androidx/wear/tiles/TileKt#timeline(kotlin.Array)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/TimelineBuilders.TimelineEntry... entries)` Creates a `https://developer.android.com/reference/androidx/wear/protolayout/TimelineBuilders.Timeline` as a collection of `https://developer.android.com/reference/androidx/wear/protolayout/TimelineBuilders.TimelineEntry` items. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/TimelineBuilders.TimelineEntry` | `https://developer.android.com/reference/androidx/wear/tiles/TileKt#timelineEntry(androidx.wear.protolayout.LayoutElementBuilders.LayoutElement,androidx.wear.protolayout.TimelineBuilders.TimeInterval)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.LayoutElement layout, https://developer.android.com/reference/androidx/wear/protolayout/TimelineBuilders.TimeInterval validity )` Creates one piece of renderable content along with the time that it is valid for. |

## Public methods

### tile

Artifact: [androidx.wear.tiles:tiles](https://developer.android.com/jetpack/androidx/releases/wear-tiles) [View Source](https://cs.android.com/search?q=file:androidx/wear/tiles/Tile.kt+function:tile) Added in [1.6.2](https://developer.android.com/jetpack/androidx/releases/wear-tiles#1.6.2)

```
public static final @NonNull TileBuilders.Tile tile(
    @NonNull TimelineBuilders.Timeline timeline,
    Duration freshness,
    @RequiresSchemaVersion(major = 1, minor = 200) StateBuilders.State state,
    String resourcesVersion
)
```

Creates a tile from the defined parameters and layout components defined in the `https://developer.android.com/reference/androidx/wear/protolayout/TimelineBuilders.Timeline` that can be rendered by a tile renderer.

Example of usage to create a tile from the given `https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.LayoutElement` for 1 entry: `tile(timeline = timeline(timelineEntry(tileLayout())))`. For more Kotlin friendly support and automatic, more performant resources handling, see `https://developer.android.com/reference/androidx/wear/tiles/Material3TileService`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/TimelineBuilders.Timeline timeline` | The `https://developer.android.com/reference/androidx/wear/protolayout/TimelineBuilders.Timeline` containing the layouts for the tiles to show in the carousel, along with their validity periods. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.time/-duration/index.html freshness` | How many elapsed time (**not** wall clock time) this tile can be considered to be "fresh". The platform will attempt to refresh your tile at some point in the future after this interval has lapsed. A value of 0 here signifies that auto-refreshes should not be used (i.e. you will manually request updates via `https://developer.android.com/reference/androidx/wear/tiles/TileService#getUpdater(android.content.Context)`. This mechanism should not be used to update your tile more frequently than once a minute, and the system may throttle your updates if you request updates faster than this interval. This interval is also inexact; the system will generally update your tile if it is on-screen, or about to be on-screen, although this is not guaranteed due to system-level optimizations. Negative values will be ignored and considered as 0. |
| `@https://developer.android.com/reference/androidx/wear/protolayout/expression/RequiresSchemaVersion(major = 1, minor = 200) https://developer.android.com/reference/androidx/wear/protolayout/StateBuilders.State state` | The `https://developer.android.com/reference/androidx/wear/protolayout/StateBuilders.State` for this tile |
| `https://developer.android.com/reference/java/lang/String.html resourcesVersion` | The resource version for tile's resources used for caching the resources in system. When using better resources handling via `https://developer.android.com/reference/androidx/wear/protolayout/ProtoLayoutScope` this can be omitted. |

### timeInterval

Artifact: [androidx.wear.tiles:tiles](https://developer.android.com/jetpack/androidx/releases/wear-tiles) [View Source](https://cs.android.com/search?q=file:androidx/wear/tiles/Tile.kt+function:timeInterval) Added in [1.6.2](https://developer.android.com/jetpack/androidx/releases/wear-tiles#1.6.2)

```
public static final @NonNull TimelineBuilders.TimeInterval timeInterval(@NonNull Duration start, @NonNull Duration end)
```

Creates a time interval, typically used to describe the validity period of a `https://developer.android.com/reference/androidx/wear/protolayout/TimelineBuilders.TimelineEntry`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.time/-duration/index.html start` | The starting point of the time interval, since the Unix epoch |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.time/-duration/index.html end` | The end point of the time interval, since the Unix epoch |

### timeline

Artifact: [androidx.wear.tiles:tiles](https://developer.android.com/jetpack/androidx/releases/wear-tiles) [View Source](https://cs.android.com/search?q=file:androidx/wear/tiles/Tile.kt+function:timeline) Added in [1.6.2](https://developer.android.com/jetpack/androidx/releases/wear-tiles#1.6.2)

```
public static final @NonNull TimelineBuilders.Timeline timeline(@NonNull TimelineBuilders.TimelineEntry... entries)
```

Creates a `https://developer.android.com/reference/androidx/wear/protolayout/TimelineBuilders.Timeline` as a collection of `https://developer.android.com/reference/androidx/wear/protolayout/TimelineBuilders.TimelineEntry` items.

`https://developer.android.com/reference/androidx/wear/protolayout/TimelineBuilders.TimelineEntry` items can be used to update a tile layout on-screen at known times, without having to explicitly update a layout. This allows for cases where, say, a calendar can be used to show the next event, and automatically switch to showing the next event when one has passed.

The active `https://developer.android.com/reference/androidx/wear/protolayout/TimelineBuilders.TimelineEntry` is switched, at most, once a minute. In the case where the validity periods of `https://developer.android.com/reference/androidx/wear/protolayout/TimelineBuilders.TimelineEntry` items overlap, the item with the shortest\* validity period will be shown. This allows a layout provider to show a "default" layout, and override it at set points without having to explicitly insert the default layout between the "override" layout.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/TimelineBuilders.TimelineEntry... entries` | The list of one or more `https://developer.android.com/reference/androidx/wear/protolayout/TimelineBuilders.TimelineEntry`. If your tile only has 1 `https://developer.android.com/reference/androidx/wear/protolayout/TimelineBuilders.TimelineEntry`, cleaner helper method to use instead of this one is `https://developer.android.com/reference/androidx/wear/protolayout/TimelineBuilders.Timeline#fromLayoutElement(androidx.wear.protolayout.LayoutElementBuilders.LayoutElement)` where `https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.LayoutElement` can be passed in directly. |

### timelineEntry

Artifact: [androidx.wear.tiles:tiles](https://developer.android.com/jetpack/androidx/releases/wear-tiles) [View Source](https://cs.android.com/search?q=file:androidx/wear/tiles/Tile.kt+function:timelineEntry) Added in [1.6.2](https://developer.android.com/jetpack/androidx/releases/wear-tiles#1.6.2)

```
public static final @NonNull TimelineBuilders.TimelineEntry timelineEntry(
    @NonNull LayoutElementBuilders.LayoutElement layout,
    TimelineBuilders.TimeInterval validity
)
```

Creates one piece of renderable content along with the time that it is valid for.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.LayoutElement layout` | The contents of this timeline entry, root `https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.LayoutElement` of tile |
| `https://developer.android.com/reference/androidx/wear/protolayout/TimelineBuilders.TimeInterval validity` | The validity period for this timeline entry. If not set, this entry doesn't expire. |