Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Ctors](https://developer.android.com/reference/android/hardware/lights/ColorSequence.Builder#pubctors) \| [Methods](https://developer.android.com/reference/android/hardware/lights/ColorSequence.Builder#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/hardware/lights/ColorSequence.Builder#inhmethods)

# ColorSequence.Builder

*** ** * ** ***

` public static final class ColorSequence.Builder `   
` extends https://developer.android.com/reference/java/lang/Object ` ` `

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.hardware.lights.ColorSequence.Builder |

<br />

*** ** * ** ***

Builder for `https://developer.android.com/reference/android/hardware/lights/ColorSequence` objects.

## Summary

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/hardware/lights/ColorSequence.Builder#Builder()() ` |

| ### Public methods ||
|---|---|
| ` https://developer.android.com/reference/android/hardware/lights/ColorSequence.Builder` | ` https://developer.android.com/reference/android/hardware/lights/ColorSequence.Builder#addControlPoint(long,%20int)(long delayMillis, int color) ` Adds the next control point for the effect. |
| ` https://developer.android.com/reference/android/hardware/lights/ColorSequence.Builder` | ` https://developer.android.com/reference/android/hardware/lights/ColorSequence.Builder#addControlPoints(android.hardware.lights.ColorSequence)(https://developer.android.com/reference/android/hardware/lights/ColorSequence sequence) ` Appends the provided ColorSequence to this sequence. |
| ` https://developer.android.com/reference/android/hardware/lights/ColorSequence.Builder` | ` https://developer.android.com/reference/android/hardware/lights/ColorSequence.Builder#addControlPoints(long[],%20int[])(long[] delaysMillis, int[] colors) ` Adds multiple control points to the sequence. |
| ` https://developer.android.com/reference/android/hardware/lights/ColorSequence` | ` https://developer.android.com/reference/android/hardware/lights/ColorSequence.Builder#build()() ` Builds the light effect. |
| ` https://developer.android.com/reference/android/hardware/lights/ColorSequence.Builder` | ` https://developer.android.com/reference/android/hardware/lights/ColorSequence.Builder#setInterpolationMode(int)(int interpolationMode) ` Sets the interpolation mode to use to transition between control point colors. |

### Inherited methods

From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.

## Public constructors

### Builder

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

```
public Builder ()
```

<br />

<br />

## Public methods

### addControlPoint

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

```
public ColorSequence.Builder addControlPoint (long delayMillis, 
                int color)
```

Adds the next control point for the effect. The transition between control point colors takes `delayMillis` milliseconds. During that time, the light colors will be smoothly interpolated from the start to the end value according to the interpolation algorithm and the light's update interval.

When specifying a delay:

- Any negative value is considered an error and will cause an `IllegalArgumentException`
- Any positive value corresponds to the transition time in milliseconds, relative to the end of the previous control point.
- A value of 0 can only be specified for the very first control point in the sequence as a way to provide an initial state for the effect. It will cause an IllegalArgumentException if found in any other index.
- All delays MUST be whole multiples of the light's update period (frame period) (`https://developer.android.com/reference/android/hardware/lights/Light#getMinUpdatePeriodMillis()`). If any specified delay is a fractional number of frames, the system will truncate the delay potentially altering initially expected interpolation values and relative timing with other lights.

Providing an initial state is not required and the effect will take the last known state as the starting point for the interpolation, creating smooth transitions between effects.

<br />

| Parameters ||
|---|---|
| `delayMillis` | `long`: transition time for the light to change to the target color. <br /> |
| `color` | `int`: the target color for the light at the end of the transition time. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/hardware/lights/ColorSequence.Builder` | a reference to this builder. This value cannot be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if delaysMillis is 0 for a non initial condition, or negative. |

### addControlPoints

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

```
public ColorSequence.Builder addControlPoints (ColorSequence sequence)
```

Appends the provided ColorSequence to this sequence.

If the two color sequences have different interpolation modes, the interpolation mode of the builder takes precedence over the interpolation mode from the argument.

<br />

| Parameters ||
|---|---|
| `sequence` | `ColorSequence`: An existing ColorSequence to append to this builder. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/hardware/lights/ColorSequence.Builder` | a reference to this builder. This value cannot be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if the sequence would cause the final sequence to be invalid. |

**See also:**

- `https://developer.android.com/reference/android/hardware/lights/ColorSequence.Builder#addControlPoint(long,%20int)`

### addControlPoints

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

```
public ColorSequence.Builder addControlPoints (long[] delaysMillis, 
                int[] colors)
```

Adds multiple control points to the sequence.

Both arrays provided MUST have the same size and be in the order in which they should be inserted.

<br />

| Parameters ||
|---|---|
| `delaysMillis` | `long`: array with the delays for the colors in the colors parameter. This value cannot be `null`. <br /> |
| `colors` | `int`: array with the control point color targets. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/hardware/lights/ColorSequence.Builder` | a reference to this builder. This value cannot be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if the arrays have different sizes or the sequence contains invalid values. |

**See also:**

- `https://developer.android.com/reference/android/hardware/lights/ColorSequence.Builder#addControlPoint(long,%20int)`

### build

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

```
public ColorSequence build ()
```

Builds the light effect.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/hardware/lights/ColorSequence` | the color sequence with the configuration provided. This value cannot be `null`. <br /> |

### setInterpolationMode

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

```
public ColorSequence.Builder setInterpolationMode (int interpolationMode)
```

Sets the interpolation mode to use to transition between control point colors.

By default, the builder configures the sequence with `https://developer.android.com/reference/android/hardware/lights/ColorSequence#INTERPOLATION_MODE_LINEAR`.

<br />

| Parameters ||
|---|---|
| `interpolationMode` | `int`: specifying how to ramp the light between control points. Value is one of the following: - `https://developer.android.com/reference/android/hardware/lights/ColorSequence#INTERPOLATION_MODE_NONE` - `https://developer.android.com/reference/android/hardware/lights/ColorSequence#INTERPOLATION_MODE_LINEAR` |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/hardware/lights/ColorSequence.Builder` | This value cannot be `null`. <br /> |