Control
class Control : Parcelable
kotlin.Any | |
↳ | android.service.controls.Control |
Represents a physical object that can be represented by a ControlTemplate
and whose properties may be modified through a ControlAction
. The information is provided by a ControlsProviderService
and represents static information (not current status) about the device.
Each control needs a unique (per provider) identifier that is persistent across reboots of the system.
Each Control
will have a name, a subtitle and will optionally belong to a structure and zone. Some of these values are defined by the user and/or the ControlsProviderService
and will be used to display the control as well as group them for management.
Each object will have an associated DeviceTypes
. This will determine the icons and colors used to display it.
An Intent
linking to the provider Activity that expands on this Control
and allows for further actions should be provided.
Summary
Nested classes | |
---|---|
Builder class for |
|
Builder class for |
Constants | |
---|---|
static Int |
The |
static Int |
Used to indicate that there was a temporary error while loading the device state. |
static Int |
The device corresponding to the |
static Int |
Used to indicate that the state of the device was successfully retrieved. |
static Int |
Reserved for use with the |
Inherited constants | |
---|---|
Public methods | |
---|---|
Int | |
PendingIntent | |
String | |
ControlTemplate | |
ColorStateList? |
Optional color to be shown with the |
Icon? |
Optional icon to be shown with the |
Int | |
Int | |
CharSequence | |
CharSequence? |
Optional top-level group to help define the |
CharSequence | |
CharSequence |
getTitle() |
CharSequence? |
getZone() Optional group name to help define the |
Boolean | |
Unit |
writeToParcel(dest: Parcel, flags: Int) Flatten this object in to a Parcel. |
Properties | |
---|---|
static Parcelable.Creator<Control!> |
Constants
STATUS_DISABLED
static val STATUS_DISABLED: Int
The Control
is currently disabled. A default error message will be displayed in place of any custom text that was set through StatefulBuilder#setStatusText
.
Value: 4
STATUS_ERROR
static val STATUS_ERROR: Int
Used to indicate that there was a temporary error while loading the device state. A default error message will be displayed in place of any custom text that was set through StatefulBuilder#setStatusText
.
Value: 3
STATUS_NOT_FOUND
static val STATUS_NOT_FOUND: Int
The device corresponding to the Control
cannot be found or was removed. The user will be alerted and directed to the application to resolve.
Value: 2
STATUS_OK
static val STATUS_OK: Int
Used to indicate that the state of the device was successfully retrieved. This includes all scenarios where the device may have a warning for the user, such as "Lock jammed", or "Vacuum stuck". Any information for the user should be set through StatefulBuilder#setStatusText
.
Value: 1
STATUS_UNKNOWN
static val STATUS_UNKNOWN: Int
Reserved for use with the StatelessBuilder
, and while loading. When state is requested via ControlsProviderService#createPublisherFor
, use other status codes to indicate the proper device state.
Value: 0
Public methods
describeContents
fun describeContents(): Int
Return | |
---|---|
Int |
a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either 0 or android.os.Parcelable#CONTENTS_FILE_DESCRIPTOR |
getAppIntent
fun getAppIntent(): PendingIntent
Return | |
---|---|
PendingIntent |
a PendingIntent linking to an Activity for the Control This value cannot be null . |
getControlId
fun getControlId(): String
Return | |
---|---|
String |
the identifier for the Control This value cannot be null . |
getControlTemplate
fun getControlTemplate(): ControlTemplate
Return | |
---|---|
ControlTemplate |
instance of ControlTemplate , that defines how the Control will behave and what interactions are available to the user This value cannot be null . |
getCustomColor
fun getCustomColor(): ColorStateList?
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.
Return | |
---|---|
ColorStateList? |
background color to use This value may be null . |
getCustomIcon
fun getCustomIcon(): Icon?
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.
Return | |
---|---|
Icon? |
icon to show This value may be null . |
getDeviceType
fun getDeviceType(): Int
getStatus
fun getStatus(): Int
Return | |
---|---|
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 |
getStatusText
fun getStatusText(): CharSequence
Return | |
---|---|
CharSequence |
user-facing text description of the Control 's status, describing its current state This value cannot be null . |
getStructure
fun getStructure(): CharSequence?
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.
Return | |
---|---|
CharSequence? |
name of the structure containing the control This value may be null . |
getSubtitle
fun getSubtitle(): CharSequence
Return | |
---|---|
CharSequence |
additional information about the Control , to appear underneath the title This value cannot be null . |
getTitle
fun getTitle(): CharSequence
Return | |
---|---|
CharSequence |
the user facing name of the Control This value cannot be null . |
getZone
fun getZone(): CharSequence?
Optional group name to help define the Control
's location within a structure, visible to the user. A structure contains zones which contains controls.
Return | |
---|---|
CharSequence? |
name of the zone containing the control This value may be null . |
isAuthRequired
fun isAuthRequired(): Boolean
Return | |
---|---|
Boolean |
true if the control can not be interacted with until the device is unlocked |
writeToParcel
fun writeToParcel(
dest: Parcel,
flags: Int
): Unit
Flatten this object in to a Parcel.
Parameters | |
---|---|
dest |
Parcel: This value cannot be null . |
flags |
Int: Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE . Value is either 0 or a combination of android.os.Parcelable#PARCELABLE_WRITE_RETURN_VALUE , and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES |