# Print output for @column tags ?>
Developers

- Design
- Develop
- Distribute

Developer Console

## Most visited

## Recently visited

## Results for

Summary: Inherited Constants | Inherited Fields | Methods | Inherited Methods

# HapticGenerator

`public class HapticGenerator`
`` `extends AudioEffect` `implements AutoCloseable`

java.lang.Object
↳ | android.media.audiofx.AudioEffect
| ↳ | android.media.audiofx.HapticGenerator

Haptic Generator(HG).

HG is an audio post-processor which generates haptic data based on the audio channels. The generated haptic data is sent along with audio data down to the audio HAL, which will require the device to support audio-coupled-haptic playback. In that case, the effect will only be created on device supporting audio-coupled-haptic playback. Call `HapticGenerator#isAvailable()` to check if the device supports this effect.

An application can create a HapticGenerator object to initiate and control this audio effect in the audio framework.

To attach the HapticGenerator to a particular AudioTrack or MediaPlayer, specify the audio session ID of this AudioTrack or MediaPlayer when constructing the HapticGenerator.

See `MediaPlayer.getAudioSessionId()` for details on audio sessions.

See `AudioEffect` class for more details on controlling audio effects.

## Summary

### Inherited constants
From class `android.media.audiofx.AudioEffect`
`String` | `ACTION_CLOSE_AUDIO_EFFECT_CONTROL_SESSION` Intent to signal to the effect control application or service that an audio session is closed and that effects should not be applied anymore.
`String` | `ACTION_DISPLAY_AUDIO_EFFECT_CONTROL_PANEL` Intent to launch an audio effect control panel UI.
`String` | `ACTION_OPEN_AUDIO_EFFECT_CONTROL_SESSION` Intent to signal to the effect control application or service that a new audio session is opened and requires audio effects to be applied.
`int` | `ALREADY_EXISTS` Internal operation status.
`int` | `CONTENT_TYPE_GAME` Value for `EXTRA_CONTENT_TYPE` when the type of content played is game audio
`int` | `CONTENT_TYPE_MOVIE` Value for `EXTRA_CONTENT_TYPE` when the type of content played is video or movie
`int` | `CONTENT_TYPE_MUSIC` Value for `EXTRA_CONTENT_TYPE` when the type of content played is music
`int` | `CONTENT_TYPE_VOICE` Value for `EXTRA_CONTENT_TYPE` when the type of content played is voice audio
`String` | `EFFECT_AUXILIARY` Effect connection mode is auxiliary.
`String` | `EFFECT_INSERT` Effect connection mode is insert.
`String` | `EFFECT_POST_PROCESSING` Effect connection mode is post processing.
`String` | `EFFECT_PRE_PROCESSING` Effect connection mode is pre processing.
`int` | `ERROR` Unspecified error.
`int` | `ERROR_BAD_VALUE` Operation failed due to bad parameter value.
`int` | `ERROR_DEAD_OBJECT` Operation failed due to dead remote object.
`int` | `ERROR_INVALID_OPERATION` Operation failed because it was requested in wrong state.
`int` | `ERROR_NO_INIT` Operation failed due to bad object initialization.
`int` | `ERROR_NO_MEMORY` Operation failed due to lack of memory.
`String` | `EXTRA_AUDIO_SESSION` Contains the ID of the audio session the effects should be applied to.
`String` | `EXTRA_CONTENT_TYPE` Indicates which type of content is played by the application.
`String` | `EXTRA_PACKAGE_NAME` Contains the package name of the calling application.
`int` | `SUCCESS` Successful operation.

### Inherited fields
From class `android.media.audiofx.AudioEffect`
`public static final UUID` | `EFFECT_TYPE_AEC` UUID for Acoustic Echo Canceler (AEC)
`public static final UUID` | `EFFECT_TYPE_AGC` UUID for Automatic Gain Control (AGC)
`public static final UUID` | `EFFECT_TYPE_BASS_BOOST` UUID for bass boost effect
`public static final UUID` | `EFFECT_TYPE_DYNAMICS_PROCESSING` UUID for Dynamics Processing
`public static final UUID` | `EFFECT_TYPE_ENV_REVERB` UUID for environmental reverberation effect
`public static final UUID` | `EFFECT_TYPE_EQUALIZER` UUID for equalizer effect
`public static final UUID` | `EFFECT_TYPE_HAPTIC_GENERATOR` UUID for Haptic Generator.
`public static final UUID` | `EFFECT_TYPE_LOUDNESS_ENHANCER` UUID for Loudness Enhancer
`public static final UUID` | `EFFECT_TYPE_NS` UUID for Noise Suppressor (NS)
`public static final UUID` | `EFFECT_TYPE_PRESET_REVERB` UUID for preset reverberation effect
`public static final UUID` | `EFFECT_TYPE_VIRTUALIZER` UUID for virtualizer effect

### Public methods
`void` | `close()` Release the resources that are held by the effect.
`static HapticGenerator` | `create(int audioSession)` Creates a HapticGenerator and attaches it to the given audio session.
`static boolean` | `isAvailable()`
`void` | `release()` Releases the native AudioEffect resources.
`int` | `setEnabled(boolean enabled)` Enable or disable the effect.

### Inherited methods
From class `android.media.audiofx.AudioEffect`
`void` | `finalize()` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
`AudioEffect.Descriptor` | `getDescriptor()` Get the effect descriptor.
`boolean` | `getEnabled()` Returns effect enabled state
`int` | `getId()` Returns effect unique identifier.
`boolean` | `hasControl()` Checks if this AudioEffect object is controlling the effect engine.
`static Descriptor[]` | `queryEffects()` Query all effects available on the platform.
`void` | `release()` Releases the native AudioEffect resources.
`void` | `setControlStatusListener(AudioEffect.OnControlStatusChangeListener listener)` Sets the listener AudioEffect notifies when the effect engine control is taken or returned.
`void` | `setEnableStatusListener(AudioEffect.OnEnableStatusChangeListener listener)` Sets the listener AudioEffect notifies when the effect engine is enabled or disabled.
`int` | `setEnabled(boolean enabled)` Enable or disable the effect.
From class `java.lang.Object`
`Object` | `clone()` Creates and returns a copy of this object.
`boolean` | `equals(Object obj)` Indicates whether some other object is "equal to" this one.
`void` | `finalize()` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
`final Class<?>` | `getClass()` Returns the runtime class of this `Object`.
`int` | `hashCode()` Returns a hash code value for the object.
`final void` | `notify()` Wakes up a single thread that is waiting on this object's monitor.
`final void` | `notifyAll()` Wakes up all threads that are waiting on this object's monitor.
`String` | `toString()` Returns a string representation of the object.
`final void` | `wait(long timeout, int nanos)` Causes the current thread to wait until another thread invokes the `notify()` method or the `notifyAll()` method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.
`final void` | `wait(long timeout)` Causes the current thread to wait until either another thread invokes the `notify()` method or the `notifyAll()` method for this object, or a specified amount of time has elapsed.
`final void` | `wait()` Causes the current thread to wait until another thread invokes the `notify()` method or the `notifyAll()` method for this object.
From interface `java.lang.AutoCloseable`
`abstract void` | `close()` Closes this resource, relinquishing any underlying resources.

## Public methods

### close

    public void close ()

Release the resources that are held by the effect.

### create

    public static HapticGenerator create (int audioSession)

Creates a HapticGenerator and attaches it to the given audio session. Use `AudioTrack.getAudioSessionId()` or `MediaPlayer.getAudioSessionId()` to apply this effect on specific AudioTrack or MediaPlayer instance.

Parameters
`audioSession` | `int`: system wide unique audio session identifier. The HapticGenerator will be applied to the players with the same audio session.

Returns
`HapticGenerator` | HapticGenerator created or null if the device does not support HapticGenerator or the audio session is invalid.

Throws
`IllegalArgumentException` | when HapticGenerator is not supported
`UnsupportedOperationException` | when the effect library is not loaded.
`RuntimeException` | for all other error

### isAvailable

    public static boolean isAvailable ()

Returns
`boolean` | true if the HapticGenerator is available on the device.

### release

    public void release ()

Releases the native AudioEffect resources.

### setEnabled

    public int setEnabled (boolean enabled)

Enable or disable the effect.

Parameters
`enabled` | `boolean`: the requested enable state

Returns
`int` | `AudioEffect.SUCCESS` in case of success, `AudioEffect.ERROR_INVALID_OPERATION` or `AudioEffect.ERROR_DEAD_OBJECT` in case of failure.

Full name *
Email address *
Company / developer name
One of your Play Store app URLs *
Which best describes your business:*
Apps
Games
Apps & Games
*
*