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:
- Device type:
DeviceTypes.TYPE_UNKNOWN - Title:
"" - Subtitle:
"" - Status:
STATUS_UNKNOWN - Control template:
ControlTemplate.getNoTemplateObject - Status text:
"" - Auth Required:
true
Summary
| Public constructors | |
|---|---|
StatefulBuilder(control: Control)Creates a |
|
StatefulBuilder(controlId: String, appIntent: PendingIntent) |
|
Public constructors
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. |
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. |
Public methods
build
fun build(): Control
| Return | |
|---|---|
Control |
a valid Control This value cannot be null. |
setAppIntent
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
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
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
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
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
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
fun setDeviceType(deviceType: Int): Control.StatefulBuilder
| Return | |
|---|---|
Control.StatefulBuilder |
this This value cannot be null. |
setStatus
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 one of the following: |
| Return | |
|---|---|
Control.StatefulBuilder |
this This value cannot be null. |
setStatusText
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
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
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
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
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. |