LightState


public final class LightState
extends Object implements Parcelable

java.lang.Object
   ↳ android.hardware.lights.LightState


Represents the state of a device light.

Controlling the color and brightness of a light is done on a best-effort basis. Each of the R, G and B channels represent the intensities of the respective part of an RGB LED, if that is supported. For devices that only support on or off lights, everything that's not off will turn the light on. If the light is monochrome and only the brightness can be controlled, the RGB color will be converted to only a brightness value and that will be used for the light's single channel.

Summary

Nested classes

class LightState.Builder

Builder for creating device light change requests. 

Inherited constants

Fields

public static final Creator<LightState> CREATOR

Public methods

int describeContents()

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation.

int getColor()

Returns the color and intensity associated with this LightState.

int getPlayerId()

Returns the player ID associated with this LightState for Light with type Light.LIGHT_TYPE_PLAYER_ID, or 0 for other types.

String toString()

Returns a string representation of the object.

void writeToParcel(Parcel dest, int flags)

Flatten this object in to a Parcel.

Inherited methods

Fields

CREATOR

Added in API level 31
public static final Creator<LightState> CREATOR

Public methods

describeContents

Added in API level 31
public int describeContents ()

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. For example, if the object will include a file descriptor in the output of writeToParcel(android.os.Parcel, int), the return value of this method must include the CONTENTS_FILE_DESCRIPTOR bit.

Returns
int a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either 0 or CONTENTS_FILE_DESCRIPTOR

getColor

Added in API level 31
public int getColor ()

Returns the color and intensity associated with this LightState.

Returns
int the color and intensity in ARGB format. The A channel is ignored. return 0 when calling LightsManager.getLightState with Light.LIGHT_TYPE_PLAYER_ID.

getPlayerId

Added in API level 31
public int getPlayerId ()

Returns the player ID associated with this LightState for Light with type Light.LIGHT_TYPE_PLAYER_ID, or 0 for other types.

Returns
int the player ID.

toString

Added in API level 31
public String toString ()

Returns a string representation of the object.

Returns
String a string representation of the object.

writeToParcel

Added in API level 31
public void writeToParcel (Parcel dest, 
                int flags)

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.PARCELABLE_WRITE_RETURN_VALUE. Value is either 0 or a combination of Parcelable.PARCELABLE_WRITE_RETURN_VALUE, and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES