ShortTextComplicationData.Builder

public final class ShortTextComplicationData.Builder


Builder for ShortTextComplicationData.

You must at a minimum set the text and contentDescription fields.

Summary

Public constructors

Builder(
    @NonNull ComplicationText text,
    @NonNull ComplicationText contentDescription
)

Public methods

@NonNull ShortTextComplicationData

Builds the ShortTextComplicationData.

final @NonNull ShortTextComplicationData.Builder

Sets the ComponentName of the ComplicationDataSourceService that provided this ComplicationData, if any.

final @NonNull ShortTextComplicationData.Builder
@RequiresApi(value = 33)
setDisplayPolicy(int displayPolicy)

Sets the complication's display policy.

final @NonNull ShortTextComplicationData.Builder

Sets the complication's fallback, used in case any dynamic value cannot be evaluated, e.g. when a data source is not available.

final @NonNull ShortTextComplicationData.Builder

Sets optional icon associated with the complication data.

final @NonNull ShortTextComplicationData.Builder
@RequiresApi(value = 33)
setPersistencePolicy(int persistencePolicy)

Sets the complication's persistence policy.

final @NonNull ShortTextComplicationData.Builder

Sets optional image associated with the complication data.

final @NonNull ShortTextComplicationData.Builder

Sets optional pending intent to be invoked when the complication is tapped.

final @NonNull ShortTextComplicationData.Builder

Sets optional title associated with the complication data.

final @NonNull ShortTextComplicationData.Builder
setValidTimeRange(TimeRange validTimeRange)

Sets optional time range during which the complication has to be shown.

Public constructors

Builder

Added in 1.0.0
public Builder(
    @NonNull ComplicationText text,
    @NonNull ComplicationText contentDescription
)
Parameters
@NonNull ComplicationText text

The main localized ComplicationText. This must be less than 7 characters long

@NonNull ComplicationText contentDescription

Defines localized text that briefly describes content of the complication. This property is used primarily for accessibility. Since some complications do not have textual representation this attribute can be used for providing such. Please do not include the word 'complication' in the description.

Public methods

build

Added in 1.0.0
public @NonNull ShortTextComplicationData build()

Builds the ShortTextComplicationData.

setDataSource

Added in 1.1.0
public final @NonNull ShortTextComplicationData.Builder setDataSource(ComponentName dataSource)

Sets the ComponentName of the ComplicationDataSourceService that provided this ComplicationData, if any.

Note a ComplicationDataSourceService does not need to call this because the system will set this value on its behalf.

setDisplayPolicy

Added in 1.2.0
@RequiresApi(value = 33)
public final @NonNull ShortTextComplicationData.Builder setDisplayPolicy(int displayPolicy)

Sets the complication's display policy.

setDynamicValueInvalidationFallback

Added in 1.3.0-alpha01
public final @NonNull ShortTextComplicationData.Builder setDynamicValueInvalidationFallback(
    ShortTextComplicationData fallback
)

Sets the complication's fallback, used in case any dynamic value cannot be evaluated, e.g. when a data source is not available.

IMPORTANT: This is only used when the system supports dynamic values. See each dynamic value field's fallback companion field for the situation where the system does not support dynamic values at all.

setMonochromaticImage

Added in 1.0.0
public final @NonNull ShortTextComplicationData.Builder setMonochromaticImage(MonochromaticImage monochromaticImage)

Sets optional icon associated with the complication data.

setPersistencePolicy

Added in 1.2.0
@RequiresApi(value = 33)
public final @NonNull ShortTextComplicationData.Builder setPersistencePolicy(int persistencePolicy)

Sets the complication's persistence policy.

setSmallImage

Added in 1.2.0
public final @NonNull ShortTextComplicationData.Builder setSmallImage(SmallImage smallImage)

Sets optional image associated with the complication data.

setTapAction

Added in 1.0.0
public final @NonNull ShortTextComplicationData.Builder setTapAction(PendingIntent tapAction)

Sets optional pending intent to be invoked when the complication is tapped.

setTitle

Added in 1.0.0
public final @NonNull ShortTextComplicationData.Builder setTitle(ComplicationText title)

Sets optional title associated with the complication data.

setValidTimeRange

Added in 1.0.0
public final @NonNull ShortTextComplicationData.Builder setValidTimeRange(TimeRange validTimeRange)

Sets optional time range during which the complication has to be shown.