# ComplicationText

Artifact: [androidx.wear.watchface:watchface-complications-data](https://developer.android.com/jetpack/androidx/releases/wear-watchface) [View Source](https://cs.android.com/search?q=file:androidx/wear/watchface/complications/data/Text.kt+class:androidx.wear.watchface.complications.data.ComplicationText) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/wear-watchface#1.0.0)

*** ** * ** ***


```
public interface ComplicationText
```

<br />

Known direct subclasses [DynamicComplicationText](https://developer.android.com/reference/androidx/wear/watchface/complications/data/DynamicComplicationText), [PlainComplicationText](https://developer.android.com/reference/androidx/wear/watchface/complications/data/PlainComplicationText), [TimeDifferenceComplicationText](https://developer.android.com/reference/androidx/wear/watchface/complications/data/TimeDifferenceComplicationText), [TimeFormatComplicationText](https://developer.android.com/reference/androidx/wear/watchface/complications/data/TimeFormatComplicationText)

|---|---|
| `https://developer.android.com/reference/androidx/wear/watchface/complications/data/DynamicComplicationText` | A `https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationText` where the system evaluates a `https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicBuilders.DynamicString`. |
| `https://developer.android.com/reference/androidx/wear/watchface/complications/data/PlainComplicationText` | A `https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationText` that contains plain text. |
| `https://developer.android.com/reference/androidx/wear/watchface/complications/data/TimeDifferenceComplicationText` | A `https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationText` that represents a time difference. |
| `https://developer.android.com/reference/androidx/wear/watchface/complications/data/TimeFormatComplicationText` | A `https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationText` that shows a formatted time. |

*** ** * ** ***

The text within a complication.

This text may change over time and this interface provides both a way to determine the current text to show with `https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationText#getTextAt(android.content.res.Resources,java.time.Instant)` but also a way to know whether the text needs to be re-rendered, by means of `https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationText#returnsSameText(java.time.Instant,java.time.Instant)`, `https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationText#getNextChangeTime(java.time.Instant)`, and `https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationText#isAlwaysEmpty()`.

## Summary

| ### Public fields |
|---|---|
| `default static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationText` | `https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationText#EMPTY()` |
| `default static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationText` | `https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationText#PLACEHOLDER()` For use when the real data isn't available yet, this `https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationText` should be rendered as a placeholder. |

| ### Public methods |
|---|---|
| `abstract @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/time/Instant.html` | `https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationText#getNextChangeTime(java.time.Instant)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/time/Instant.html afterInstant)` Returns the next time after `https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationText#getNextChangeTime(java.time.Instant)` at which the text may change. |
| `abstract @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/CharSequence.html` | `https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationText#getTextAt(android.content.res.Resources,java.time.Instant)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/res/Resources.html resources, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/time/Instant.html instant)` Returns the text that should be displayed for the given timestamp. |
| `abstract boolean` | `https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationText#isAlwaysEmpty()()` |
| `abstract boolean` | `https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationText#returnsSameText(java.time.Instant,java.time.Instant)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/time/Instant.html firstInstant, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/time/Instant.html secondInstant )` Returns true if the result of `https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationText#getTextAt(android.content.res.Resources,java.time.Instant)` will be the same for both `https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationText#returnsSameText(java.time.Instant,java.time.Instant)` and `https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationText#returnsSameText(java.time.Instant,java.time.Instant)`. |

## Public fields

### EMPTY

```
default static final @NonNull ComplicationText EMPTY
```

### PLACEHOLDER

```
default static final @NonNull ComplicationText PLACEHOLDER
```

For use when the real data isn't available yet, this `https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationText` should be rendered as a placeholder. It is suggested that it should be rendered with a light grey box.

Note a placeholder may only be used in the context of `https://developer.android.com/reference/androidx/wear/watchface/complications/data/NoDataComplicationData#placeholder()`.

## Public methods

### getNextChangeTime

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

```
abstract @NonNull Instant getNextChangeTime(@NonNull Instant afterInstant)
```

Returns the next time after `https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationText#getNextChangeTime(java.time.Instant)` at which the text may change.

### getTextAt

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

```
abstract @NonNull CharSequence getTextAt(@NonNull Resources resources, @NonNull Instant instant)
```

Returns the text that should be displayed for the given timestamp.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/res/Resources.html resources` | `https://developer.android.com/reference/android/content/res/Resources.html` from the current context |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/time/Instant.html instant` | The `https://developer.android.com/reference/java/time/Instant.html` at which to sample the text |

### isAlwaysEmpty

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

```
abstract boolean isAlwaysEmpty()
```

### returnsSameText

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

```
abstract boolean returnsSameText(
    @NonNull Instant firstInstant,
    @NonNull Instant secondInstant
)
```

Returns true if the result of `https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationText#getTextAt(android.content.res.Resources,java.time.Instant)` will be the same for both `https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationText#returnsSameText(java.time.Instant,java.time.Instant)` and `https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationText#returnsSameText(java.time.Instant,java.time.Instant)`.