# DynamicComplicationText

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.DynamicComplicationText) Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/wear-watchface#1.2.0)

*** ** * ** ***

<br />

```
@RequiresApi(value = 33)
public final class DynamicComplicationText implements ComplicationText
```

<br />

*** ** * ** ***

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`. By the time this reaches the watch face's Renderer, it'll have been converted to a plain ComplicationText.

## Summary

| ### Public constructors |
|---|
| `@https://developer.android.com/reference/androidx/annotation/RequiresApi(value = 34) https://developer.android.com/reference/androidx/wear/watchface/complications/data/DynamicComplicationText#DynamicComplicationText(androidx.wear.protolayout.expression.DynamicBuilders.DynamicString)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicBuilders.DynamicString dynamicValue )` Creates a `https://developer.android.com/reference/androidx/wear/watchface/complications/data/DynamicComplicationText` with no `https://developer.android.com/reference/androidx/wear/watchface/complications/data/DynamicComplicationText#fallbackValue()` for API levels that are known to support dynamic values. |
| `https://developer.android.com/reference/androidx/wear/watchface/complications/data/DynamicComplicationText#DynamicComplicationText(androidx.wear.protolayout.expression.DynamicBuilders.DynamicString,kotlin.CharSequence)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicBuilders.DynamicString dynamicValue, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/CharSequence.html fallbackValue )` |

| ### Public methods |
|---|---|
| `boolean` | `https://developer.android.com/reference/androidx/wear/watchface/complications/data/DynamicComplicationText#equals(kotlin.Any)(https://developer.android.com/reference/java/lang/Object.html other)` |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicBuilders.DynamicString` | `https://developer.android.com/reference/androidx/wear/watchface/complications/data/DynamicComplicationText#getDynamicValue()()` The `https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicBuilders.DynamicString` which will be evaluated into a value dynamically. |
| `final @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/DynamicComplicationText#getFallbackValue()()` Used when the system does not support `https://developer.android.com/reference/androidx/wear/watchface/complications/data/DynamicComplicationText#dynamicValue()`. |
| `@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/DynamicComplicationText#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. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/CharSequence.html` | `https://developer.android.com/reference/androidx/wear/watchface/complications/data/DynamicComplicationText#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. |
| `int` | `https://developer.android.com/reference/androidx/wear/watchface/complications/data/DynamicComplicationText#hashCode()()` |
| `boolean` | `https://developer.android.com/reference/androidx/wear/watchface/complications/data/DynamicComplicationText#isAlwaysEmpty()()` |
| `boolean` | `https://developer.android.com/reference/androidx/wear/watchface/complications/data/DynamicComplicationText#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)`. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/wear/watchface/complications/data/DynamicComplicationText#toString()()` |

## Public constructors

### DynamicComplicationText

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

```
@RequiresApi(value = 34)
public DynamicComplicationText(
    @NonNull DynamicBuilders.DynamicString dynamicValue
)
```

Creates a `https://developer.android.com/reference/androidx/wear/watchface/complications/data/DynamicComplicationText` with no `https://developer.android.com/reference/androidx/wear/watchface/complications/data/DynamicComplicationText#fallbackValue()` for API levels that are known to support dynamic values.

### DynamicComplicationText

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

```
public DynamicComplicationText(
    @NonNull DynamicBuilders.DynamicString dynamicValue,
    @NonNull CharSequence fallbackValue
)
```

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicBuilders.DynamicString dynamicValue` | The `https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicBuilders.DynamicString` which will be evaluated into a value dynamically. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/CharSequence.html fallbackValue` | Used when the system does not support `https://developer.android.com/reference/androidx/wear/watchface/complications/data/DynamicComplicationText#dynamicValue()`. This is only relevant before `https://developer.android.com/reference/android/os/Build.VERSION_CODES.html#UPSIDE_DOWN_CAKE`, use the no-fallback constructor if you target an equal or higher API level. IMPORTANT: This is only used when the system does not support `https://developer.android.com/reference/androidx/wear/watchface/complications/data/DynamicComplicationText#dynamicValue()` *at all* . See `https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationData#dynamicValueInvalidationFallback()` for the situation where the `https://developer.android.com/reference/androidx/wear/watchface/complications/data/DynamicComplicationText#dynamicValue()` cannot be evaluated, e.g. when a data source is not available. |

## Public methods

### equals

```
public boolean equals(Object other)
```

### getDynamicValue

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

```
public final @NonNull DynamicBuilders.DynamicString getDynamicValue()
```

The `https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicBuilders.DynamicString` which will be evaluated into a value dynamically.

### getFallbackValue

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

```
public final @NonNull CharSequence getFallbackValue()
```

Used when the system does not support `https://developer.android.com/reference/androidx/wear/watchface/complications/data/DynamicComplicationText#dynamicValue()`.

This is only relevant before `https://developer.android.com/reference/android/os/Build.VERSION_CODES.html#UPSIDE_DOWN_CAKE`, use the no-fallback constructor if you target an equal or higher API level.

IMPORTANT: This is only used when the system does not support `https://developer.android.com/reference/androidx/wear/watchface/complications/data/DynamicComplicationText#dynamicValue()` *at all* . See `https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationData#dynamicValueInvalidationFallback()` for the situation where the `https://developer.android.com/reference/androidx/wear/watchface/complications/data/DynamicComplicationText#dynamicValue()` cannot be evaluated, e.g. when a data source is not available.

### getNextChangeTime

```
public @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

```
public @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 |

### hashCode

```
public int hashCode()
```

### isAlwaysEmpty

```
public boolean isAlwaysEmpty()
```

### returnsSameText

```
public 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)`.

### toString

```
public @NonNull String toString()
```