VibratorManager  |  API reference  |  Android Developers (original) (raw)


public abstract class VibratorManager
extends [Object](/reference/java/lang/Object) ``


Provides access to all vibrators from the device, as well as the ability to run them in a synchronized fashion.

If your process exits, any vibration you started will stop.

Summary

Public methods
abstract void cancel() Turn all the vibrators off.
abstractVibrator getDefaultVibrator() Returns the default Vibrator for the device.
abstractVibrator getVibrator(int vibratorId) Retrieve a single vibrator by id.
abstract int[] getVibratorIds() List all available vibrator ids, returning a possible empty list.
final void vibrate(CombinedVibration effect) Vibrate with a given combination of effects.
final void vibrate(CombinedVibration effect, VibrationAttributes attributes) Vibrate with a given combination of effects.
Inherited methods
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. finalClass<?> 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 timeoutMillis, int nanos) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed. final void wait(long timeoutMillis) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed. final void wait() Causes the current thread to wait until it is awakened, typically by being notified or interrupted.

Public methods

getDefaultVibrator

public abstract Vibrator getDefaultVibrator ()

Returns the default Vibrator for the device.

Returns
Vibrator This value cannot be null.

getVibrator

public abstract Vibrator getVibrator (int vibratorId)

Retrieve a single vibrator by id.

Parameters
vibratorId int: The id of the vibrator to be retrieved.
Returns
Vibrator The vibrator with given vibratorId, never null.

getVibratorIds

public abstract int[] getVibratorIds ()

List all available vibrator ids, returning a possible empty list.

Returns
int[] An array containing the ids of the vibrators available on the device. This value cannot be null.

vibrate

public final void vibrate (CombinedVibration effect)

Vibrate with a given combination of effects.

Pass in a [CombinedVibration](/reference/android/os/CombinedVibration) representing a combination of [VibrationEffects](/reference/android/os/VibrationEffect) to be played on one or more vibrators.

The app should be in foreground for the vibration to happen.

Requires [Manifest.permission.VIBRATE](/reference/android/Manifest.permission#VIBRATE)

Parameters
effect CombinedVibration: a combination of effects to be performed by one or more vibrators. This value cannot be null.