Stay organized with collections
Save and categorize content based on your preferences.
Builder
class Builder
Builder for creating device light change requests.
Summary
Public constructors
Public methods
setColor
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: the desired color and intensity in ARGB format. |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# LightState.Builder\n\nAdded in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nBuilder\n=======\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/hardware/lights/LightState.Builder \"View this page in Java\") \n\n```\nclass Builder\n```\n\n|---|-------------------------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||\n| ↳ | [android.hardware.lights.LightState.Builder](#) |\n\nBuilder for creating device light change requests.\n\nSummary\n-------\n\n| Public constructors ||\n|------------------------------------------------------------------|---|\n| [Builder](#Builder())`()` Creates a new [LightState.Builder](#). |\n\n| Public methods ||\n|--------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [LightState](/reference/kotlin/android/hardware/lights/LightState) | [build](#build())`()` Create a LightState object used to control lights on the device. |\n| [LightState.Builder](#) | [setColor](#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. |\n| [LightState.Builder](#) | [setPlayerId](#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](/reference/kotlin/android/hardware/lights/Light#LIGHT_TYPE_PLAYER_ID:kotlin.Int). |\n\nPublic constructors\n-------------------\n\n### Builder\n\nAdded in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nBuilder()\n```\n\nCreates a new [LightState.Builder](#).\n\nPublic methods\n--------------\n\n### build\n\nAdded in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun build(): LightState\n```\n\nCreate a LightState object used to control lights on the device.\n\nThe generated [LightState](/reference/kotlin/android/hardware/lights/LightState) should be used in [LightsRequest.Builder.addLight(Light, LightState)](/reference/kotlin/android/hardware/lights/LightsRequest.Builder#addLight(android.hardware.lights.Light,%20android.hardware.lights.LightState)).\n\n| Return ||\n|--------------------------------------------------------------------|------------------------------|\n| [LightState](/reference/kotlin/android/hardware/lights/LightState) | This value cannot be `null`. |\n\n### setColor\n\nAdded in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun setColor(color: Int): LightState.Builder\n```\n\nSet the desired color and intensity of the LightState Builder, for a light type of RBG color or single monochrome color.\n\n| Parameters ||\n|---------|-----------------------------------------------------------------------------------------------------------------------------|\n| `color` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): the desired color and intensity in ARGB format. |\n\n| Return ||\n|-------------------------|---------------------------------------------------------------------------------------------------------|\n| [LightState.Builder](#) | The [LightState.Builder](#) object contains the light color and intensity. This value cannot be `null`. |\n\n### setPlayerId\n\nAdded in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun setPlayerId(playerId: Int): LightState.Builder\n```\n\nSet the desired player id of the LightState Builder, for a light with type [android.hardware.lights.Light#LIGHT_TYPE_PLAYER_ID](/reference/kotlin/android/hardware/lights/Light#LIGHT_TYPE_PLAYER_ID:kotlin.Int).\n\n| Parameters ||\n|------------|----------------------------------------------------------------------------------------------------|\n| `playerId` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): the desired player id. |\n\n| Return ||\n|-------------------------|-----------------------------------------------------------------------------------------|\n| [LightState.Builder](#) | The [LightState.Builder](#) object contains the player id. This value cannot be `null`. |"]]