WatchState

class WatchState


Describes the current state of the wearable including some hardware details such as whether or not it supports burn in prevention and low-bit ambient.

Summary

Public constructors

WatchState(
    interruptionFilter: StateFlow<Int?>,
    isAmbient: StateFlow<Boolean?>,
    isBatteryLowAndNotCharging: StateFlow<Boolean?>,
    isVisible: StateFlow<Boolean?>,
    hasLowBitAmbient: Boolean,
    hasBurnInProtection: Boolean,
    analogPreviewReferenceTimeMillis: Long,
    digitalPreviewReferenceTimeMillis: Long,
    chinHeight: Int,
    isHeadless: Boolean
)

This function is deprecated. WatchState constructors without watchFaceInstanceId are deprecated

WatchState(
    interruptionFilter: StateFlow<Int?>,
    isAmbient: StateFlow<Boolean?>,
    isBatteryLowAndNotCharging: StateFlow<Boolean?>,
    isVisible: StateFlow<Boolean?>,
    hasLowBitAmbient: Boolean,
    hasBurnInProtection: Boolean,
    analogPreviewReferenceTimeMillis: Long,
    digitalPreviewReferenceTimeMillis: Long,
    chinHeight: @Px Int,
    isHeadless: Boolean,
    watchFaceInstanceId: StateFlow<String>
)

Public properties

Long

UTC reference time for previews of analog watch faces in milliseconds since the epoch.

Int

the size, in pixels, of the chin or zero if the device does not have a chin.

Long

UTC reference time for previews of digital watch faces in milliseconds since the epoch.

Boolean

Whether or not the watch hardware supports burn in protection.

Boolean

Whether or not the watch hardware supports low bit ambient support.

StateFlow<Int?>

The current user interruption settings.

StateFlow<Boolean?>

Whether or not the watch is in ambient mode.

StateFlow<Boolean?>

Whether or not we should conserve power due to a low battery which isn't charging.

Boolean

Whether or not this is a headless watchface.

StateFlow<Boolean?>

Whether or not the watch face is visible.

StateFlow<String>

The ID associated with the watch face instance.

Public constructors

WatchState

Added in 1.0.0
Deprecated in 1.1.0
WatchState(
    interruptionFilter: StateFlow<Int?>,
    isAmbient: StateFlow<Boolean?>,
    isBatteryLowAndNotCharging: StateFlow<Boolean?>,
    isVisible: StateFlow<Boolean?>,
    hasLowBitAmbient: Boolean,
    hasBurnInProtection: Boolean,
    analogPreviewReferenceTimeMillis: Long,
    digitalPreviewReferenceTimeMillis: Long,
    chinHeight: Int,
    isHeadless: Boolean
)

WatchState

Added in 1.1.0
WatchState(
    interruptionFilter: StateFlow<Int?>,
    isAmbient: StateFlow<Boolean?>,
    isBatteryLowAndNotCharging: StateFlow<Boolean?>,
    isVisible: StateFlow<Boolean?>,
    hasLowBitAmbient: Boolean,
    hasBurnInProtection: Boolean,
    analogPreviewReferenceTimeMillis: Long,
    digitalPreviewReferenceTimeMillis: Long,
    chinHeight: @Px Int,
    isHeadless: Boolean,
    watchFaceInstanceId: StateFlow<String>
)
Parameters
interruptionFilter: StateFlow<Int?>

The current user interruption settings. See NotificationManager. This is initially null because the watch face is created before the system has sent the state. Based on the value the watch face should adjust the amount of information it displays. For example, if it displays the number of pending emails, it should hide it if interruptionFilter is equal to NotificationManager.INTERRUPTION_FILTER_NONE. interruptionFilter can be NotificationManager.INTERRUPTION_FILTER_NONE, NotificationManager.INTERRUPTION_FILTER_PRIORITY, NotificationManager.INTERRUPTION_FILTER_ALL, NotificationManager.INTERRUPTION_FILTER_ALARMS, or NotificationManager.INTERRUPTION_FILTER_UNKNOWN.

isAmbient: StateFlow<Boolean?>

Whether or not the watch is in ambient mode. This is initially null because the watch face is created before the system has sent the state. The order in which ambient vs style changes are reported is not guaranteed. Likewise the order of isAmbient flow callbacks and Renderer.CanvasRenderer.render or Renderer.GlesRenderer.render calls is not defined. For rendering please refer to RenderParameters.drawMode instead of isAmbient because you might receive requests for rendering non-ambient frames while the watch is ambient (e.g. editing from the companion phone).

isBatteryLowAndNotCharging: StateFlow<Boolean?>

Whether or not we should conserve power due to a low battery which isn't charging. This is initially null because the watch face is created before the system has sent the state. Only valid if android.support.wearable.watchface.WatchFaceStyle.hideNotificationIndicator is true.

isVisible: StateFlow<Boolean?>

Whether or not the watch face is visible. This is initially null because the watch face is created before the system has sent the state.

hasLowBitAmbient: Boolean

Whether or not the watch hardware supports low bit ambient support.

hasBurnInProtection: Boolean

Whether or not the watch hardware supports burn in protection.

analogPreviewReferenceTimeMillis: Long

UTC reference time for previews of analog watch faces in milliseconds since the epoch.

digitalPreviewReferenceTimeMillis: Long

UTC reference time for previews of digital watch faces in milliseconds since the epoch.

chinHeight: @Px Int

the size, in pixels, of the chin or zero if the device does not have a chin. A chin is a section at the bottom of a circular display that is visible due to hardware limitations.

isHeadless: Boolean

Whether or not this is a headless watchface.

watchFaceInstanceId: StateFlow<String>

The ID associated with the watch face instance. Note there may be more than one instance associated with a WatchFaceService. See androidx.wear.watchface.client.WatchFaceId for more details.

Public properties

analogPreviewReferenceTimeMillis

Added in 1.0.0
val analogPreviewReferenceTimeMillisLong

UTC reference time for previews of analog watch faces in milliseconds since the epoch.

chinHeight

Added in 1.0.0
val chinHeightInt

the size, in pixels, of the chin or zero if the device does not have a chin. A chin is a section at the bottom of a circular display that is visible due to hardware limitations.

digitalPreviewReferenceTimeMillis

Added in 1.0.0
val digitalPreviewReferenceTimeMillisLong

UTC reference time for previews of digital watch faces in milliseconds since the epoch.

hasBurnInProtection

Added in 1.2.0
val hasBurnInProtectionBoolean

Whether or not the watch hardware supports burn in protection.

hasLowBitAmbient

Added in 1.2.0
val hasLowBitAmbientBoolean

Whether or not the watch hardware supports low bit ambient support.

interruptionFilter

Added in 1.0.0
val interruptionFilterStateFlow<Int?>

The current user interruption settings. See NotificationManager. This is initially null because the watch face is created before the system has sent the state. Based on the value the watch face should adjust the amount of information it displays. For example, if it displays the number of pending emails, it should hide it if interruptionFilter is equal to NotificationManager.INTERRUPTION_FILTER_NONE. interruptionFilter can be NotificationManager.INTERRUPTION_FILTER_NONE, NotificationManager.INTERRUPTION_FILTER_PRIORITY, NotificationManager.INTERRUPTION_FILTER_ALL, NotificationManager.INTERRUPTION_FILTER_ALARMS, or NotificationManager.INTERRUPTION_FILTER_UNKNOWN.

isAmbient

Added in 1.0.0
val isAmbientStateFlow<Boolean?>

Whether or not the watch is in ambient mode. This is initially null because the watch face is created before the system has sent the state. The order in which ambient vs style changes are reported is not guaranteed. Likewise the order of isAmbient flow callbacks and Renderer.CanvasRenderer.render or Renderer.GlesRenderer.render calls is not defined. For rendering please refer to RenderParameters.drawMode instead of isAmbient because you might receive requests for rendering non-ambient frames while the watch is ambient (e.g. editing from the companion phone).

isBatteryLowAndNotCharging

Added in 1.1.0
val isBatteryLowAndNotChargingStateFlow<Boolean?>

Whether or not we should conserve power due to a low battery which isn't charging. This is initially null because the watch face is created before the system has sent the state. Only valid if android.support.wearable.watchface.WatchFaceStyle.hideNotificationIndicator is true.

isHeadless

Added in 1.0.0
val isHeadlessBoolean

Whether or not this is a headless watchface.

isVisible

Added in 1.0.0
val isVisibleStateFlow<Boolean?>

Whether or not the watch face is visible. This is initially null because the watch face is created before the system has sent the state.

watchFaceInstanceId

Added in 1.1.0
val watchFaceInstanceIdStateFlow<String>

The ID associated with the watch face instance. Note there may be more than one instance associated with a WatchFaceService. See androidx.wear.watchface.client.WatchFaceId for more details.