# Print output for @column tags ?> VibrationEffect.Composition - Android SDK | Android Developers

Most visited

Recently visited

VibrationEffect.Composition

public static final class VibrationEffect.Composition
extends Object

java.lang.Object
   ↳ android.os.VibrationEffect.Composition


A composition of haptic primitives that, when combined, create a single haptic effect.

See also:

Summary

Constants

int PRIMITIVE_CLICK

This effect should produce a sharp, crisp click sensation.

int PRIMITIVE_QUICK_FALL

A haptic effect that simulates quick downwards movement with gravity.

int PRIMITIVE_QUICK_RISE

A haptic effect that simulates quick upward movement against gravity.

int PRIMITIVE_SLOW_RISE

A haptic effect that simulates slow upward movement against gravity.

int PRIMITIVE_TICK

This very short effect should produce a light crisp sensation intended to be used repetitively for dynamic feedback.

Public methods

VibrationEffect.Composition addPrimitive(int primitiveId)

Add a haptic primitive to the end of the current composition.

VibrationEffect.Composition addPrimitive(int primitiveId, float scale, int delay)

Add a haptic primitive to the end of the current composition.

VibrationEffect.Composition addPrimitive(int primitiveId, float scale)

Add a haptic primitive to the end of the current composition.

VibrationEffect compose()

Compose all of the added primitives together into a single VibrationEffect.

Inherited methods

Constants

PRIMITIVE_CLICK

public static final int PRIMITIVE_CLICK

This effect should produce a sharp, crisp click sensation.

Constant Value: 1 (0x00000001)

PRIMITIVE_QUICK_FALL

public static final int PRIMITIVE_QUICK_FALL

A haptic effect that simulates quick downwards movement with gravity.

Constant Value: 6 (0x00000006)

PRIMITIVE_QUICK_RISE

public static final int PRIMITIVE_QUICK_RISE

A haptic effect that simulates quick upward movement against gravity.

Constant Value: 4 (0x00000004)

PRIMITIVE_SLOW_RISE

public static final int PRIMITIVE_SLOW_RISE

A haptic effect that simulates slow upward movement against gravity.

Constant Value: 5 (0x00000005)

PRIMITIVE_TICK

public static final int PRIMITIVE_TICK

This very short effect should produce a light crisp sensation intended to be used repetitively for dynamic feedback.

Constant Value: 7 (0x00000007)

Public methods

addPrimitive

public VibrationEffect.Composition addPrimitive (int primitiveId)

Add a haptic primitive to the end of the current composition. Similar to addPrimitive(int, float, int), but with no delay and a default scale applied.

Parameters
primitiveId int: The primitive to add Value is PRIMITIVE_CLICK, android.os.VibrationEffect.Composition.PRIMITIVE_THUD, android.os.VibrationEffect.Composition.PRIMITIVE_SPIN, PRIMITIVE_QUICK_RISE, PRIMITIVE_SLOW_RISE, PRIMITIVE_QUICK_FALL, or PRIMITIVE_TICK

Returns
VibrationEffect.Composition The Composition object to enable adding multiple primitives in one chain. This value cannot be null.

addPrimitive

public VibrationEffect.Composition addPrimitive (int primitiveId, 
                float scale, 
                int delay)

Add a haptic primitive to the end of the current composition.

Parameters
primitiveId int: The primitive to add Value is PRIMITIVE_CLICK, android.os.VibrationEffect.Composition.PRIMITIVE_THUD, android.os.VibrationEffect.Composition.PRIMITIVE_SPIN, PRIMITIVE_QUICK_RISE, PRIMITIVE_SLOW_RISE, PRIMITIVE_QUICK_FALL, or PRIMITIVE_TICK

scale float: The scale to apply to the intensity of the primitive. Value is between 0f and 1f inclusive

delay int: The amount of time, in milliseconds, to wait between playing the prior primitive and this one Value is 0 or greater

Returns
VibrationEffect.Composition The Composition object to enable adding multiple primitives in one chain. This value cannot be null.

addPrimitive

public VibrationEffect.Composition addPrimitive (int primitiveId, 
                float scale)

Add a haptic primitive to the end of the current composition. Similar to addPrimitive(int, float, int), but with no delay.

Parameters
primitiveId int: The primitive to add Value is PRIMITIVE_CLICK, android.os.VibrationEffect.Composition.PRIMITIVE_THUD, android.os.VibrationEffect.Composition.PRIMITIVE_SPIN, PRIMITIVE_QUICK_RISE, PRIMITIVE_SLOW_RISE, PRIMITIVE_QUICK_FALL, or PRIMITIVE_TICK

scale float: The scale to apply to the intensity of the primitive. Value is between 0f and 1f inclusive

Returns
VibrationEffect.Composition The Composition object to enable adding multiple primitives in one chain. This value cannot be null.

compose

public VibrationEffect compose ()

Compose all of the added primitives together into a single VibrationEffect. The Composition object is still valid after this call, so you can continue adding more primitives to it and generating more VibrationEffects by calling this method again.

Returns
VibrationEffect The VibrationEffect resulting from the composition of the primitives. This value cannot be null.