Added in API level 30

StatefulBuilder


class StatefulBuilder
kotlin.Any
   ↳ android.service.controls.Control.StatefulBuilder

Builder class for Control that contains state information. State information is passed through an instance of a ControlTemplate and will determine how the user can interact with the Control. User interactions will be sent through the method call ControlsProviderService.performControlAction with an instance of ControlAction to convey any potential new value. Must be used to provide controls for ControlsProviderService.createPublisherFor. It provides the following defaults for non-optional parameters:

Summary

Public constructors

Creates a StatelessBuilder using an existing Control as a base.

StatefulBuilder(controlId: String, appIntent: PendingIntent)

Public methods
Control

Control.StatefulBuilder

Control.StatefulBuilder
setAuthRequired(authRequired: Boolean)

Control.StatefulBuilder
setControlId(controlId: String)

Control.StatefulBuilder

Set the ControlTemplate to define the primary user interaction Devices may support a variety of user interactions, and all interactions cannot be represented with a single ControlTemplate.

Control.StatefulBuilder

Optional color to be shown with the Control.

Control.StatefulBuilder
setCustomIcon(customIcon: Icon?)

Optional icon to be shown with the Control.

Control.StatefulBuilder
setDeviceType(deviceType: Int)

Control.StatefulBuilder
setStatus(status: Int)

Control.StatefulBuilder

Control.StatefulBuilder

Optional top-level group to help define the Control's location, visible to the user.

Control.StatefulBuilder

Control.StatefulBuilder

Control.StatefulBuilder

Optional group name to help define the Control's location within a structure, visible to the user.

Public constructors

StatefulBuilder

Added in API level 30
StatefulBuilder(control: Control)

Creates a StatelessBuilder using an existing Control as a base.

Parameters
control Control: base for the builder. This value cannot be null.

StatefulBuilder

Added in API level 30
StatefulBuilder(
    controlId: String,
    appIntent: PendingIntent)
Parameters
controlId String: the identifier for the Control. This value cannot be null.
appIntent PendingIntent: the pending intent linking to the device Activity. This value cannot be null.

Public methods

build

Added in API level 30
fun build(): Control
Return
Control a valid Control This value cannot be null.

setAppIntent

Added in API level 30
fun setAppIntent(appIntent: PendingIntent): Control.StatefulBuilder
Parameters
appIntent PendingIntent: a PendingIntent linking to an Activity for the Control This value cannot be null.
Return
Control.StatefulBuilder this This value cannot be null.

setAuthRequired

Added in API level 33
fun setAuthRequired(authRequired: Boolean): Control.StatefulBuilder
Parameters
authRequired Boolean: true if the control can not be interacted with until the device is unlocked
Return
Control.StatefulBuilder this This value cannot be null.

setControlId

Added in API level 30
fun setControlId(controlId: String): Control.StatefulBuilder
Parameters
controlId String: the identifier for the Control. This value cannot be null.
Return
Control.StatefulBuilder this This value cannot be null.

setControlTemplate

Added in API level 30
fun setControlTemplate(controlTemplate: ControlTemplate): Control.StatefulBuilder

Set the ControlTemplate to define the primary user interaction Devices may support a variety of user interactions, and all interactions cannot be represented with a single ControlTemplate. Therefore, the selected template should be most closely aligned with what the expected primary device action will be. Any secondary interactions can be done via the setAppIntent(android.app.PendingIntent).

Parameters
controlTemplate ControlTemplate: instance of ControlTemplate, that defines how the Control will behave and what interactions are available to the user This value cannot be null.
Return
Control.StatefulBuilder this This value cannot be null.

setCustomColor

Added in API level 30
fun setCustomColor(customColor: ColorStateList?): Control.StatefulBuilder

Optional color to be shown with the Control. It is highly recommended to let the system default the color unless the default is not suitable for the application.

Parameters
customColor ColorStateList?: background color to use This value may be null.
Return
Control.StatefulBuilder this This value cannot be null.

setCustomIcon

Added in API level 30
fun setCustomIcon(customIcon: Icon?): Control.StatefulBuilder

Optional icon to be shown with the Control. It is highly recommended to let the system default the icon unless the default icon is not suitable.

Parameters
customIcon Icon?: icon to show This value may be null.
Return
Control.StatefulBuilder this This value cannot be null.

setDeviceType

Added in API level 30
fun setDeviceType(deviceType: Int): Control.StatefulBuilder
Parameters
deviceType Int: type of device represented by this Control, used to determine the default icon and color Value is android.service.controls.DeviceTypes#TYPE_GENERIC_ON_OFF, android.service.controls.DeviceTypes#TYPE_GENERIC_START_STOP, android.service.controls.DeviceTypes#TYPE_GENERIC_OPEN_CLOSE, android.service.controls.DeviceTypes#TYPE_GENERIC_LOCK_UNLOCK, android.service.controls.DeviceTypes#TYPE_GENERIC_ARM_DISARM, android.service.controls.DeviceTypes#TYPE_GENERIC_TEMP_SETTING, android.service.controls.DeviceTypes#TYPE_GENERIC_VIEWSTREAM, android.service.controls.DeviceTypes#TYPE_UNKNOWN, android.service.controls.DeviceTypes#TYPE_AC_HEATER, android.service.controls.DeviceTypes#TYPE_AC_UNIT, android.service.controls.DeviceTypes#TYPE_AIR_FRESHENER, android.service.controls.DeviceTypes#TYPE_AIR_PURIFIER, android.service.controls.DeviceTypes#TYPE_COFFEE_MAKER, android.service.controls.DeviceTypes#TYPE_DEHUMIDIFIER, android.service.controls.DeviceTypes#TYPE_DISPLAY, android.service.controls.DeviceTypes#TYPE_FAN, android.service.controls.DeviceTypes#TYPE_HOOD, android.service.controls.DeviceTypes#TYPE_HUMIDIFIER, android.service.controls.DeviceTypes#TYPE_KETTLE, android.service.controls.DeviceTypes#TYPE_LIGHT, android.service.controls.DeviceTypes#TYPE_MICROWAVE, android.service.controls.DeviceTypes#TYPE_OUTLET, android.service.controls.DeviceTypes#TYPE_RADIATOR, android.service.controls.DeviceTypes#TYPE_REMOTE_CONTROL, android.service.controls.DeviceTypes#TYPE_SET_TOP, android.service.controls.DeviceTypes#TYPE_STANDMIXER, android.service.controls.DeviceTypes#TYPE_STYLER, android.service.controls.DeviceTypes#TYPE_SWITCH, android.service.controls.DeviceTypes#TYPE_TV, android.service.controls.DeviceTypes#TYPE_WATER_HEATER, android.service.controls.DeviceTypes#TYPE_DISHWASHER, android.service.controls.DeviceTypes#TYPE_DRYER, android.service.controls.DeviceTypes#TYPE_MOP, android.service.controls.DeviceTypes#TYPE_MOWER, android.service.controls.DeviceTypes#TYPE_MULTICOOKER, android.service.controls.DeviceTypes#TYPE_SHOWER, android.service.controls.DeviceTypes#TYPE_SPRINKLER, android.service.controls.DeviceTypes#TYPE_WASHER, android.service.controls.DeviceTypes#TYPE_VACUUM, android.service.controls.DeviceTypes#TYPE_AWNING, android.service.controls.DeviceTypes#TYPE_BLINDS, android.service.controls.DeviceTypes#TYPE_CLOSET, android.service.controls.DeviceTypes#TYPE_CURTAIN, android.service.controls.DeviceTypes#TYPE_DOOR, android.service.controls.DeviceTypes#TYPE_DRAWER, android.service.controls.DeviceTypes#TYPE_GARAGE, android.service.controls.DeviceTypes#TYPE_GATE, android.service.controls.DeviceTypes#TYPE_PERGOLA, android.service.controls.DeviceTypes#TYPE_SHUTTER, android.service.controls.DeviceTypes#TYPE_WINDOW, android.service.controls.DeviceTypes#TYPE_VALVE, android.service.controls.DeviceTypes#TYPE_LOCK, android.service.controls.DeviceTypes#TYPE_SECURITY_SYSTEM, android.service.controls.DeviceTypes#TYPE_HEATER, android.service.controls.DeviceTypes#TYPE_REFRIGERATOR, android.service.controls.DeviceTypes#TYPE_THERMOSTAT, android.service.controls.DeviceTypes#TYPE_CAMERA, android.service.controls.DeviceTypes#TYPE_DOORBELL, or android.service.controls.DeviceTypes#TYPE_ROUTINE
Return
Control.StatefulBuilder this This value cannot be null.

setStatus

Added in API level 30
fun setStatus(status: Int): Control.StatefulBuilder
Parameters
status Int: status of the Control, used to convey information about the attempt to fetch the current state Value is android.service.controls.Control#STATUS_UNKNOWN, android.service.controls.Control#STATUS_OK, android.service.controls.Control#STATUS_NOT_FOUND, android.service.controls.Control#STATUS_ERROR, or android.service.controls.Control#STATUS_DISABLED
Return
Control.StatefulBuilder this This value cannot be null.

setStatusText

Added in API level 30
fun setStatusText(statusText: CharSequence): Control.StatefulBuilder
Parameters
statusText CharSequence: user-facing text description of the Control's status, describing its current state This value cannot be null.
Return
Control.StatefulBuilder this This value cannot be null.

setStructure

Added in API level 30
fun setStructure(structure: CharSequence?): Control.StatefulBuilder

Optional top-level group to help define the Control's location, visible to the user. If not present, the application name will be used as the top-level group. A structure contains zones which contains controls.

Parameters
structure CharSequence?: name of the structure containing the control This value may be null.
Return
Control.StatefulBuilder this This value cannot be null.

setSubtitle

Added in API level 30
fun setSubtitle(subtitle: CharSequence): Control.StatefulBuilder
Parameters
subtitle CharSequence: additional information about the Control, to appear underneath the title This value cannot be null.
Return
Control.StatefulBuilder this This value cannot be null.

setTitle

Added in API level 30
fun setTitle(title: CharSequence): Control.StatefulBuilder
Parameters
title CharSequence: the user facing name of the Control This value cannot be null.
Return
Control.StatefulBuilder this This value cannot be null.

setZone

Added in API level 30
fun setZone(zone: CharSequence?): Control.StatefulBuilder

Optional group name to help define the Control's location within a structure, visible to the user. A structure contains zones which contains controls.

Parameters
zone CharSequence?: name of the zone containing the control This value may be null.
Return
Control.StatefulBuilder this This value cannot be null.