Preset


class Preset
kotlin.Any
   ↳ android.os.VibrationEffect.Preset

Represents a predefined haptics pattern, corresponding to android.os.VibrationEffect.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
static Int

A sharp, short pulse sensation.

static Int

A very short, low-frequency pulse sensation.

static Int

A very short pulse sensation.

Public methods
static VibrationEffect.Preset
create(presetId: Int)

Creates a new haptic Preset with the specified ID.

static VibrationEffect.Preset
create(presetId: Int, scale: Float)

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

Constants

PRESET_CLICK

static val PRESET_CLICK: Int

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

Value: 1

PRESET_LOW_TICK

static val PRESET_LOW_TICK: Int

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

Value: 8

PRESET_TICK

static val PRESET_TICK: Int

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

Value: 7

Public methods

create

static fun create(presetId: Int): VibrationEffect.Preset

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:
Return
VibrationEffect.Preset The created Preset.
This value cannot be null.

create

static fun create(
    presetId: Int,
    scale: Float
): VibrationEffect.Preset

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
Return
VibrationEffect.Preset The created Preset.
This value cannot be null.
Exceptions
java.lang.IllegalArgumentException if the scale is not between 0 and 1.