VibrationEffect.Preset


public static final class VibrationEffect.Preset
extends Object

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


Represents a predefined haptics pattern, corresponding to ERROR(Composition.PrimitiveType/android.os.VibrationEffect.Composition#PrimitiveType Composition.PrimitiveType).

These presets are building blocks that can be added to a VibrationEffect.Builder to create more complex haptic compositions. They represent common, short haptic sensations.

Summary

Constants

int PRESET_CLICK

A sharp, short pulse sensation.

int PRESET_LOW_TICK

A very short, low-frequency pulse sensation.

int PRESET_TICK

A very short pulse sensation.

Public methods

static VibrationEffect.Preset create(int presetId, float scale)

Creates a new haptic Preset with the specified ID and scale.

static VibrationEffect.Preset create(int presetId)

Creates a new haptic Preset with the specified ID.

Inherited methods

Constants

PRESET_CLICK

Added in API level 10000
public static final int PRESET_CLICK

A sharp, short pulse sensation. This is the unified identifier for a click effect.

Constant Value: 1 (0x00000001)

PRESET_LOW_TICK

Added in API level 10000
public static final int PRESET_LOW_TICK

A very short, low-frequency pulse sensation. This is the unified identifier for a low tick effect.

Constant Value: 8 (0x00000008)

PRESET_TICK

Added in API level 10000
public static final int PRESET_TICK

A very short pulse sensation. This is the unified identifier for a tick effect.

Constant Value: 7 (0x00000007)

Public methods

create

Added in API level 10000
public static VibrationEffect.Preset create (int presetId, 
                float scale)

Creates a new haptic Preset with the specified ID and scale.

Parameters
presetId int: The ID of the preset to create.
Value is one of the following:
scale float: The scale to apply to the preset's intensity, ranging from 0 to 1.
Value is between 0.0f and 1.0f inclusive

Returns
VibrationEffect.Preset The created Preset.
This value cannot be null.

Throws
IllegalArgumentException if the scale is not between 0 and 1.

create

Added in API level 10000
public static VibrationEffect.Preset create (int presetId)

Creates a new haptic Preset with the specified ID.

Parameters
presetId int: The ID of the preset to create.
Value is one of the following:
Returns
VibrationEffect.Preset The created Preset.
This value cannot be null.