Control.StatefulBuilder


public static final class Control.StatefulBuilder
extends Object

java.lang.Object
   ↳ 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

StatefulBuilder(String controlId, PendingIntent appIntent)
StatefulBuilder(Control control)

Creates a StatelessBuilder using an existing Control as a base.

Public methods

Control build()
Control.StatefulBuilder setAppIntent(PendingIntent appIntent)
Control.StatefulBuilder setAuthRequired(boolean authRequired)
Control.StatefulBuilder setControlId(String controlId)
Control.StatefulBuilder setControlTemplate(ControlTemplate controlTemplate)

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 setCustomColor(ColorStateList customColor)

Optional color to be shown with the Control.

Control.StatefulBuilder setCustomIcon(Icon customIcon)

Optional icon to be shown with the Control.

Control.StatefulBuilder setDeviceType(int deviceType)
Control.StatefulBuilder setStatus(int status)
Control.StatefulBuilder setStatusText(CharSequence statusText)
Control.StatefulBuilder setStructure(CharSequence structure)

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

Control.StatefulBuilder setSubtitle(CharSequence subtitle)
Control.StatefulBuilder setTitle(CharSequence title)
Control.StatefulBuilder setZone(CharSequence zone)

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

Inherited methods

Public constructors

StatefulBuilder

Added in API level 30
public StatefulBuilder (String controlId, 
                PendingIntent appIntent)

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.

StatefulBuilder

Added in API level 30
public 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.

Public methods

build

Added in API level 30
public Control build ()

Returns
Control a valid Control This value cannot be null.

setAppIntent

Added in API level 30
public Control.StatefulBuilder setAppIntent (PendingIntent appIntent)

Parameters
appIntent PendingIntent: a PendingIntent linking to an Activity for the Control This value cannot be null.

Returns
Control.StatefulBuilder this This value cannot be null.

setAuthRequired

Added in API level 33
public Control.StatefulBuilder setAuthRequired (boolean authRequired)

Parameters
authRequired boolean: true if the control can not be interacted with until the device is unlocked

Returns
Control.StatefulBuilder this This value cannot be null.

setControlId

Added in API level 30
public Control.StatefulBuilder setControlId (String controlId)

Parameters
controlId String: the identifier for the Control. This value cannot be null.

Returns
Control.StatefulBuilder this This value cannot be null.

setControlTemplate

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

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.

Returns
Control.StatefulBuilder this This value cannot be null.

setCustomColor

Added in API level 30
public Control.StatefulBuilder setCustomColor (ColorStateList customColor)

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.

Returns
Control.StatefulBuilder this This value cannot be null.

setCustomIcon

Added in API level 30
public Control.StatefulBuilder setCustomIcon (Icon customIcon)

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.

Returns
Control.StatefulBuilder this This value cannot be null.

setDeviceType

Added in API level 30
public Control.StatefulBuilder setDeviceType (int deviceType)

Parameters
deviceType int: type of device represented by this Control, used to determine the default icon and color Value is DeviceTypes.TYPE_GENERIC_ON_OFF, DeviceTypes.TYPE_GENERIC_START_STOP, DeviceTypes.TYPE_GENERIC_OPEN_CLOSE, DeviceTypes.TYPE_GENERIC_LOCK_UNLOCK, DeviceTypes.TYPE_GENERIC_ARM_DISARM, DeviceTypes.TYPE_GENERIC_TEMP_SETTING, DeviceTypes.TYPE_GENERIC_VIEWSTREAM, DeviceTypes.TYPE_UNKNOWN, DeviceTypes.TYPE_AC_HEATER, DeviceTypes.TYPE_AC_UNIT, DeviceTypes.TYPE_AIR_FRESHENER, DeviceTypes.TYPE_AIR_PURIFIER, DeviceTypes.TYPE_COFFEE_MAKER, DeviceTypes.TYPE_DEHUMIDIFIER, DeviceTypes.TYPE_DISPLAY, DeviceTypes.TYPE_FAN, DeviceTypes.TYPE_HOOD, DeviceTypes.TYPE_HUMIDIFIER, DeviceTypes.TYPE_KETTLE, DeviceTypes.TYPE_LIGHT, DeviceTypes.TYPE_MICROWAVE, DeviceTypes.TYPE_OUTLET, DeviceTypes.TYPE_RADIATOR, DeviceTypes.TYPE_REMOTE_CONTROL, DeviceTypes.TYPE_SET_TOP, DeviceTypes.TYPE_STANDMIXER, DeviceTypes.TYPE_STYLER, DeviceTypes.TYPE_SWITCH, DeviceTypes.TYPE_TV, DeviceTypes.TYPE_WATER_HEATER, DeviceTypes.TYPE_DISHWASHER, DeviceTypes.TYPE_DRYER, DeviceTypes.TYPE_MOP, DeviceTypes.TYPE_MOWER, DeviceTypes.TYPE_MULTICOOKER, DeviceTypes.TYPE_SHOWER, DeviceTypes.TYPE_SPRINKLER, DeviceTypes.TYPE_WASHER, DeviceTypes.TYPE_VACUUM, DeviceTypes.TYPE_AWNING, DeviceTypes.TYPE_BLINDS, DeviceTypes.TYPE_CLOSET, DeviceTypes.TYPE_CURTAIN, DeviceTypes.TYPE_DOOR, DeviceTypes.TYPE_DRAWER, DeviceTypes.TYPE_GARAGE, DeviceTypes.TYPE_GATE, DeviceTypes.TYPE_PERGOLA, DeviceTypes.TYPE_SHUTTER, DeviceTypes.TYPE_WINDOW, DeviceTypes.TYPE_VALVE, DeviceTypes.TYPE_LOCK, DeviceTypes.TYPE_SECURITY_SYSTEM, DeviceTypes.TYPE_HEATER, DeviceTypes.TYPE_REFRIGERATOR, DeviceTypes.TYPE_THERMOSTAT, DeviceTypes.TYPE_CAMERA, DeviceTypes.TYPE_DOORBELL, or DeviceTypes.TYPE_ROUTINE

Returns
Control.StatefulBuilder this This value cannot be null.

setStatus

Added in API level 30
public Control.StatefulBuilder setStatus (int status)

Parameters
status int: status of the Control, used to convey information about the attempt to fetch the current state Value is Control.STATUS_UNKNOWN, Control.STATUS_OK, Control.STATUS_NOT_FOUND, Control.STATUS_ERROR, or Control.STATUS_DISABLED

Returns
Control.StatefulBuilder this This value cannot be null.

setStatusText

Added in API level 30
public Control.StatefulBuilder setStatusText (CharSequence statusText)

Parameters
statusText CharSequence: user-facing text description of the Control's status, describing its current state This value cannot be null.

Returns
Control.StatefulBuilder this This value cannot be null.

setStructure

Added in API level 30
public Control.StatefulBuilder setStructure (CharSequence structure)

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.

Returns
Control.StatefulBuilder this This value cannot be null.

setSubtitle

Added in API level 30
public Control.StatefulBuilder setSubtitle (CharSequence subtitle)

Parameters
subtitle CharSequence: additional information about the Control, to appear underneath the title This value cannot be null.

Returns
Control.StatefulBuilder this This value cannot be null.

setTitle

Added in API level 30
public Control.StatefulBuilder setTitle (CharSequence title)

Parameters
title CharSequence: the user facing name of the Control This value cannot be null.

Returns
Control.StatefulBuilder this This value cannot be null.

setZone

Added in API level 30
public Control.StatefulBuilder setZone (CharSequence zone)

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.

Returns
Control.StatefulBuilder this This value cannot be null.