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

# MultiLightEffect

*** ** * ** ***

```
class MultiLightEffect : Parcelable
```

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

Models an effect that will be shown in one or more lights.

Effects are comprised of \[light, ColorSequence\] pairs defining how each light should change over time along with some extra configuration values:

- Iterations: the number of times the effect will be played back to back.
- Preemptive: whether this effect should preempt any previously playing state or if it should be played after the current effect finishes.

A MultiLightEffect is treated as a unit with a given start time and an implicit duration:

- Start time: all lights sequences in the effect start at the same time, regardless of having a initial state or not.
- Duration: the duration of the effect is the duration of the longest sequence it contains. If a light sequence in the effect is shorter than the effect duration, the light will remain as a solid color until the end of the effect.

`https://developer.android.com/reference/kotlin/android/hardware/lights/ColorSequence`s in the effect could have initial states (`delay=0`) for their corresponding lights, which has special implications when the effect will be played as a continuation of another effect (effects with `preemptive=false` and/or effects with initial states and more than one iteration).

The initial state will be applied only if the effect is set to preemptive and it is the first iteration of the effect. The system ignores the initial state in subsequent iterations or in effects with `preemptive=false` to allow the light to transition smoothly and avoid flicks.

## Summary

| Nested classes ||
|---|---|
|   | `https://developer.android.com/reference/kotlin/android/hardware/lights/MultiLightEffect.Builder` Builder for `https://developer.android.com/reference/kotlin/android/hardware/lights/MultiLightEffect#` objects. |

| Inherited constants ||
|---|---|
| From class `https://developer.android.com/reference/kotlin/android/os/Parcelable.html#` |---|---| | `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/android/os/Parcelable.html#CONTENTS_FILE_DESCRIPTOR:kotlin.Int` Descriptor bit used with `https://developer.android.com/reference/kotlin/android/os/Parcelable.html#describeContents()`: indicates that the Parcelable object's flattened representation includes a file descriptor. <br /> | | `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/android/os/Parcelable.html#PARCELABLE_WRITE_RETURN_VALUE:kotlin.Int` Flag for use with `https://developer.android.com/reference/kotlin/android/os/Parcelable.html#writeToParcel(android.os.Parcel,%20kotlin.Int)`: the object being written is a return value, that is the result of a function such as "`Parcelable someFunction()`", "`void someFunction(out Parcelable)`", or "`void someFunction(inout Parcelable)`". Some implementations may want to release resources at this point. <br /> | ||

| Public methods ||
|---|---|
| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | `https://developer.android.com/reference/kotlin/android/hardware/lights/MultiLightEffect#describeContents()()` Implement the Parcelable interface |
| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | `https://developer.android.com/reference/kotlin/android/hardware/lights/MultiLightEffect#getIterations()()` Returns the number of times this effect will be played in a loop. |
| [MutableMap](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-map/index.html)\<[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)!, [ColorSequence](https://developer.android.com/reference/kotlin/android/hardware/lights/ColorSequence)!\> | `https://developer.android.com/reference/kotlin/android/hardware/lights/MultiLightEffect#getSequences()()` Returns the color sequences defined in the light effect for each of the lights. |
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | `https://developer.android.com/reference/kotlin/android/hardware/lights/MultiLightEffect#isPreemptive()()` Returns whether this effect will cancel any previously playing effect. |
| [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | `https://developer.android.com/reference/kotlin/android/hardware/lights/MultiLightEffect#toString()()` Returns a string representation of the object. |
| [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | `https://developer.android.com/reference/kotlin/android/hardware/lights/MultiLightEffect#writeToParcel(android.os.Parcel,%20kotlin.Int)(dest: https://developer.android.com/reference/kotlin/android/os/Parcel.html#, flags: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)` Implement the Parcelable interface |

| Properties ||
|---|---|
| static [Parcelable.Creator](https://developer.android.com/reference/kotlin/android/os/Parcelable.Creator.html#)\<[MultiLightEffect](https://developer.android.com/reference/kotlin/android/hardware/lights/MultiLightEffect#)!\> | `https://developer.android.com/reference/kotlin/android/hardware/lights/MultiLightEffect#CREATOR:android.os.Parcelable.Creator` Implement the Parcelable interface |

## Public methods

### describeContents

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

```
fun describeContents(): Int
```

Implement the Parcelable interface

| Return ||
|---|---|
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html` | a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either `0` or - `https://developer.android.com/reference/kotlin/android/os/Parcelable.html#CONTENTS_FILE_DESCRIPTOR:kotlin.Int` |

### getIterations

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

```
fun getIterations(): Int
```

Returns the number of times this effect will be played in a loop. Defaults to 1.

| Return ||
|---|---|
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html` | the number of iterations to play. |

### getSequences

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

```
fun getSequences(): MutableMap<Int!, ColorSequence!>
```

Returns the color sequences defined in the light effect for each of the lights.

The key for the returned map corresponds to the lightId (see `https://developer.android.com/reference/kotlin/android/hardware/lights/Light#getId()`) of the light that will play the color sequence represented by the value.

| Return ||
|---|---|
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-map/index.html<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html!, https://developer.android.com/reference/kotlin/android/hardware/lights/ColorSequence!>` | the Map of lightIds to the color sequences that will be played for the effect. This value cannot be `null`. |

### isPreemptive

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

```
fun isPreemptive(): Boolean
```

Returns whether this effect will cancel any previously playing effect.

| Return ||
|---|---|
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html` | true if this effect applies immediately, false otherwise. |

### toString

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

```
fun toString(): String
```

Returns a string representation of the object.

| Return ||
|---|---|
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html` | a string representation of the object. |

### writeToParcel

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

```
fun writeToParcel(
    dest: Parcel, 
    flags: Int
): Unit
```

Implement the Parcelable interface

| Parameters ||
|---|---|
| `dest` | [Parcel](https://developer.android.com/reference/kotlin/android/os/Parcel.html#): This value cannot be `null`. |
| `flags` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): Additional flags about how the object should be written. May be 0 or `https://developer.android.com/reference/kotlin/android/os/Parcelable.html#PARCELABLE_WRITE_RETURN_VALUE:kotlin.Int`. Value is either `0` or a combination of the following: - `https://developer.android.com/reference/kotlin/android/os/Parcelable.html#PARCELABLE_WRITE_RETURN_VALUE:kotlin.Int` |

## Properties

### CREATOR

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

```
static val CREATOR: Parcelable.Creator<MultiLightEffect!>
```

Implement the Parcelable interface