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

# ParallelCombination

*** ** * ** ***

```
class ParallelCombination
```

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

A combination of haptic effects that should be played in multiple vibrators in parallel.

## Summary

| Public methods ||
|---|---|
| [CombinedVibration.ParallelCombination](https://developer.android.com/reference/kotlin/android/os/CombinedVibration.ParallelCombination#) | `https://developer.android.com/reference/kotlin/android/os/CombinedVibration.ParallelCombination#addVibrator(kotlin.Int,%20android.os.VibrationEffect)(vibratorId: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html, effect: https://developer.android.com/reference/kotlin/android/os/VibrationEffect)` Add or replace a one shot vibration effect to be performed by the specified vibrator. |
| [CombinedVibration](https://developer.android.com/reference/kotlin/android/os/CombinedVibration) | `https://developer.android.com/reference/kotlin/android/os/CombinedVibration.ParallelCombination#combine()()` Combine all of the added effects into a `https://developer.android.com/reference/kotlin/android/os/CombinedVibration`. |

## Public methods

### addVibrator

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

```
fun addVibrator(
    vibratorId: Int, 
    effect: VibrationEffect
): CombinedVibration.ParallelCombination
```

Add or replace a one shot vibration effect to be performed by the specified vibrator.

| Parameters ||
|---|---|
| `vibratorId` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): The id of the vibrator that should perform this effect. |
| `effect` | [VibrationEffect](https://developer.android.com/reference/kotlin/android/os/VibrationEffect): The effect this vibrator should play. This value cannot be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/os/CombinedVibration.ParallelCombination#` | The `https://developer.android.com/reference/kotlin/android/os/CombinedVibration.ParallelCombination#` object to enable adding multiple effects in one chain. This value cannot be `null`. |

**See Also**

- `https://developer.android.com/reference/kotlin/android/os/VibrationEffect#createOneShot(kotlin.Long,%20kotlin.Int)`

### combine

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

```
fun combine(): CombinedVibration
```

Combine all of the added effects into a `https://developer.android.com/reference/kotlin/android/os/CombinedVibration`.

If `https://developer.android.com/reference/kotlin/android/os/CombinedVibration.ParallelCombination#` is enabled, all effects added to this combination must be consistent regarding timeline anchoring: they must either all be timeline anchored (see android.os.VibrationEffect#isTimelineAnchored()) or none of them should be.

The `https://developer.android.com/reference/kotlin/android/os/CombinedVibration.ParallelCombination#` object is still valid after this call, so you can continue adding more effects to it and generating more `https://developer.android.com/reference/kotlin/android/os/CombinedVibration`s by calling this method again.

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/os/CombinedVibration` | The `https://developer.android.com/reference/kotlin/android/os/CombinedVibration` resulting from combining the added effects to be played in parallel. This value cannot be `null`. |

| Exceptions ||
|---|---|
| `java.lang.IllegalStateException` | if the combination is empty or if it contains a mix of timeline anchored and non-timeline anchored effects. |