VibratorManager
public
abstract
class
VibratorManager
extends Object
java.lang.Object | |
↳ | android.os.VibratorManager |
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. |
abstract
Vibrator
|
getDefaultVibrator()
Returns the default Vibrator for the device. |
abstract
Vibrator
|
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 | |
---|---|
Public methods
cancel
public abstract void cancel ()
Turn all the vibrators off.
Requires Manifest.permission.VIBRATE
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
representing a combination of VibrationEffects
to be played on one or more vibrators.
The app should be in foreground for the vibration to happen.
Requires
Manifest.permission.VIBRATE
Parameters | |
---|---|
effect |
CombinedVibration : a combination of effects to be performed by one or more vibrators.
This value cannot be null . |
vibrate
public final void vibrate (CombinedVibration effect, VibrationAttributes attributes)
Vibrate with a given combination of effects.
Pass in a CombinedVibration
representing a combination of VibrationEffect
to be played on one or more vibrators.
The app should be in foreground for the vibration to happen. Background apps should specify a ringtone, notification or alarm usage in order to vibrate.
Requires
Manifest.permission.VIBRATE
Parameters | |
---|---|
effect |
CombinedVibration : a combination of effects to be performed by one or more vibrators.
This value cannot be null . |
attributes |
VibrationAttributes : VibrationAttributes corresponding to the vibration. For example,
specify VibrationAttributes.USAGE_ALARM for alarm vibrations or
VibrationAttributes.USAGE_RINGTONE for vibrations associated with
incoming calls.
This value may be null . |