StatefulBuilder
class 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
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 . |
StatefulBuilder
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
setAuthRequired
fun setAuthRequired(authRequired: Boolean): Control.StatefulBuilder
Parameters |
authRequired |
Boolean: true if the control can not be interacted with until the device is unlocked |
setCustomColor
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 . |
setCustomIcon
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 . |
setDeviceType
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 |
setStructure
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 . |
setZone
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 . |