Added in API level 30

ToggleTemplate


class ToggleTemplate : ControlTemplate

A template for a Control with a single button that can be toggled between two states. The states for the toggle correspond to the states in ControlButton.isChecked(). An action on this template will originate a BooleanAction to change that state.

Summary

Inherited constants
Int TYPE_ERROR

Type identifier of the template returned by getErrorTemplate().
Value is android.service.controls.templates.ControlTemplate#TYPE_ERROR, android.service.controls.templates.ControlTemplate#TYPE_NO_TEMPLATE, android.service.controls.templates.ControlTemplate#TYPE_TOGGLE, android.service.controls.templates.ControlTemplate#TYPE_RANGE, android.service.controls.templates.ControlTemplate#TYPE_THUMBNAIL, android.service.controls.templates.ControlTemplate#TYPE_TOGGLE_RANGE, android.service.controls.templates.ControlTemplate#TYPE_TEMPERATURE, or android.service.controls.templates.ControlTemplate#TYPE_STATELESS

Int TYPE_NO_TEMPLATE

Type identifier of ControlTemplate.getNoTemplateObject.
Value is android.service.controls.templates.ControlTemplate#TYPE_ERROR, android.service.controls.templates.ControlTemplate#TYPE_NO_TEMPLATE, android.service.controls.templates.ControlTemplate#TYPE_TOGGLE, android.service.controls.templates.ControlTemplate#TYPE_RANGE, android.service.controls.templates.ControlTemplate#TYPE_THUMBNAIL, android.service.controls.templates.ControlTemplate#TYPE_TOGGLE_RANGE, android.service.controls.templates.ControlTemplate#TYPE_TEMPERATURE, or android.service.controls.templates.ControlTemplate#TYPE_STATELESS

Int TYPE_RANGE

Type identifier of RangeTemplate.
Value is android.service.controls.templates.ControlTemplate#TYPE_ERROR, android.service.controls.templates.ControlTemplate#TYPE_NO_TEMPLATE, android.service.controls.templates.ControlTemplate#TYPE_TOGGLE, android.service.controls.templates.ControlTemplate#TYPE_RANGE, android.service.controls.templates.ControlTemplate#TYPE_THUMBNAIL, android.service.controls.templates.ControlTemplate#TYPE_TOGGLE_RANGE, android.service.controls.templates.ControlTemplate#TYPE_TEMPERATURE, or android.service.controls.templates.ControlTemplate#TYPE_STATELESS

Int TYPE_STATELESS

Type identifier of StatelessTemplate.
Value is android.service.controls.templates.ControlTemplate#TYPE_ERROR, android.service.controls.templates.ControlTemplate#TYPE_NO_TEMPLATE, android.service.controls.templates.ControlTemplate#TYPE_TOGGLE, android.service.controls.templates.ControlTemplate#TYPE_RANGE, android.service.controls.templates.ControlTemplate#TYPE_THUMBNAIL, android.service.controls.templates.ControlTemplate#TYPE_TOGGLE_RANGE, android.service.controls.templates.ControlTemplate#TYPE_TEMPERATURE, or android.service.controls.templates.ControlTemplate#TYPE_STATELESS

Int TYPE_TEMPERATURE

Type identifier of TemperatureControlTemplate.
Value is android.service.controls.templates.ControlTemplate#TYPE_ERROR, android.service.controls.templates.ControlTemplate#TYPE_NO_TEMPLATE, android.service.controls.templates.ControlTemplate#TYPE_TOGGLE, android.service.controls.templates.ControlTemplate#TYPE_RANGE, android.service.controls.templates.ControlTemplate#TYPE_THUMBNAIL, android.service.controls.templates.ControlTemplate#TYPE_TOGGLE_RANGE, android.service.controls.templates.ControlTemplate#TYPE_TEMPERATURE, or android.service.controls.templates.ControlTemplate#TYPE_STATELESS

Int TYPE_THUMBNAIL

Type identifier of ThumbnailTemplate.
Value is android.service.controls.templates.ControlTemplate#TYPE_ERROR, android.service.controls.templates.ControlTemplate#TYPE_NO_TEMPLATE, android.service.controls.templates.ControlTemplate#TYPE_TOGGLE, android.service.controls.templates.ControlTemplate#TYPE_RANGE, android.service.controls.templates.ControlTemplate#TYPE_THUMBNAIL, android.service.controls.templates.ControlTemplate#TYPE_TOGGLE_RANGE, android.service.controls.templates.ControlTemplate#TYPE_TEMPERATURE, or android.service.controls.templates.ControlTemplate#TYPE_STATELESS

Int TYPE_TOGGLE

Type identifier of ToggleTemplate.
Value is android.service.controls.templates.ControlTemplate#TYPE_ERROR, android.service.controls.templates.ControlTemplate#TYPE_NO_TEMPLATE, android.service.controls.templates.ControlTemplate#TYPE_TOGGLE, android.service.controls.templates.ControlTemplate#TYPE_RANGE, android.service.controls.templates.ControlTemplate#TYPE_THUMBNAIL, android.service.controls.templates.ControlTemplate#TYPE_TOGGLE_RANGE, android.service.controls.templates.ControlTemplate#TYPE_TEMPERATURE, or android.service.controls.templates.ControlTemplate#TYPE_STATELESS

Int TYPE_TOGGLE_RANGE

Type identifier of ToggleRangeTemplate.
Value is android.service.controls.templates.ControlTemplate#TYPE_ERROR, android.service.controls.templates.ControlTemplate#TYPE_NO_TEMPLATE, android.service.controls.templates.ControlTemplate#TYPE_TOGGLE, android.service.controls.templates.ControlTemplate#TYPE_RANGE, android.service.controls.templates.ControlTemplate#TYPE_THUMBNAIL, android.service.controls.templates.ControlTemplate#TYPE_TOGGLE_RANGE, android.service.controls.templates.ControlTemplate#TYPE_TEMPERATURE, or android.service.controls.templates.ControlTemplate#TYPE_STATELESS

Public constructors
ToggleTemplate(templateId: String, button: ControlButton)

Inherited functions
ControlTemplate getErrorTemplate()

ControlTemplate getNoTemplateObject()

Get a singleton ControlTemplate, which supports no direct user input. Used by Control.StatelessBuilder when there is no known state. Can also be used in Control.StatefulBuilder for conveying information to a user about the Control but direct user interaction is not desired. Since this template has no corresponding ControlAction, any user interaction will launch the Control.getAppIntent().

String getTemplateId()

Public constructors

ToggleTemplate

Added in API level 30
ToggleTemplate(
    templateId: String,
    button: ControlButton)
Parameters
templateId String: the identifier for this template object This value cannot be null.
button ControlButton: a ControlButton that can show the current state and toggle it This value cannot be null.

Public methods

getContentDescription

Added in API level 30
fun getContentDescription(): CharSequence
Return
CharSequence This value cannot be null.

getTemplateType

Added in API level 30
fun getTemplateType(): Int

isChecked

Added in API level 30
fun isChecked(): Boolean