# LightState.Builder

Added in[API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

# Builder

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/android/hardware/lights/LightState.Builder "View this page in Java")  

```
class Builder
```

|---|------------------------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                                           ||
| ↳ | [android.hardware.lights.LightState.Builder](https://developer.android.com/reference/kotlin/android/hardware/lights/LightState.Builder#) |

Builder for creating device light change requests.

## Summary

|                                                                                                                 Public constructors                                                                                                                  ||
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [Builder](https://developer.android.com/reference/kotlin/android/hardware/lights/LightState.Builder#Builder())`()` Creates a new[LightState.Builder](https://developer.android.com/reference/kotlin/android/hardware/lights/LightState.Builder#). |

|                                                                                                                                                                                                                                                                                        Public methods                                                                                                                                                                                                                                                                                        ||
|------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [LightState](https://developer.android.com/reference/kotlin/android/hardware/lights/LightState)                  | [build](https://developer.android.com/reference/kotlin/android/hardware/lights/LightState.Builder#build())`()` Create a LightState object used to control lights on the device.                                                                                                                                                                                                                                                                                            |
| [LightState.Builder](https://developer.android.com/reference/kotlin/android/hardware/lights/LightState.Builder#) | [setColor](https://developer.android.com/reference/kotlin/android/hardware/lights/LightState.Builder#setColor(kotlin.Int))`(`color:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Set the desired color and intensity of the LightState Builder, for a light type of RBG color or single monochrome color.                                                                                                                               |
| [LightState.Builder](https://developer.android.com/reference/kotlin/android/hardware/lights/LightState.Builder#) | [setPlayerId](https://developer.android.com/reference/kotlin/android/hardware/lights/LightState.Builder#setPlayerId(kotlin.Int))`(`playerId:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Set the desired player id of the LightState Builder, for a light with type[android.hardware.lights.Light#LIGHT_TYPE_PLAYER_ID](https://developer.android.com/reference/kotlin/android/hardware/lights/Light#LIGHT_TYPE_PLAYER_ID:kotlin.Int). |

## Public constructors

### Builder

Added in[API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
Builder()
```

Creates a new[LightState.Builder](https://developer.android.com/reference/kotlin/android/hardware/lights/LightState.Builder#).

## Public methods

### build

Added in[API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun build(): LightState
```

Create a LightState object used to control lights on the device.

The generated[LightState](https://developer.android.com/reference/kotlin/android/hardware/lights/LightState)should be used in[LightsRequest.Builder.addLight(Light, LightState)](https://developer.android.com/reference/kotlin/android/hardware/lights/LightsRequest.Builder#addLight(android.hardware.lights.Light,%20android.hardware.lights.LightState)).

|                                                            Return                                                            ||
|-------------------------------------------------------------------------------------------------|-----------------------------|
| [LightState](https://developer.android.com/reference/kotlin/android/hardware/lights/LightState) | This value cannot be`null`. |

### setColor

Added in[API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun setColor(color: Int): LightState.Builder
```

Set the desired color and intensity of the LightState Builder, for a light type of RBG color or single monochrome color.

|                                                             Parameters                                                              ||
|---------|----------------------------------------------------------------------------------------------------------------------------|
| `color` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):the desired color and intensity in ARGB format. |

|                                                                                                                                                     Return                                                                                                                                                      ||
|------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [LightState.Builder](https://developer.android.com/reference/kotlin/android/hardware/lights/LightState.Builder#) | The[LightState.Builder](https://developer.android.com/reference/kotlin/android/hardware/lights/LightState.Builder#)object contains the light color and intensity. This value cannot be`null`. |

### setPlayerId

Added in[API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun setPlayerId(playerId: Int): LightState.Builder
```

Set the desired player id of the LightState Builder, for a light with type[android.hardware.lights.Light#LIGHT_TYPE_PLAYER_ID](https://developer.android.com/reference/kotlin/android/hardware/lights/Light#LIGHT_TYPE_PLAYER_ID:kotlin.Int).

|                                                  Parameters                                                   ||
|------------|---------------------------------------------------------------------------------------------------|
| `playerId` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):the desired player id. |

|                                                                                                                                             Return                                                                                                                                              ||
|------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [LightState.Builder](https://developer.android.com/reference/kotlin/android/hardware/lights/LightState.Builder#) | The[LightState.Builder](https://developer.android.com/reference/kotlin/android/hardware/lights/LightState.Builder#)object contains the player id. This value cannot be`null`. |