VibrationEffect
public
abstract
class
VibrationEffect
extends Object
implements
Parcelable
| java.lang.Object | |
| ↳ | android.os.VibrationEffect |
A VibrationEffect describes a haptic effect to be performed by a Vibrator.
These effects may be any number of things, from single shot vibrations to complex waveforms.
Summary
Constants | |
|---|---|
int |
DEFAULT_AMPLITUDE
The default vibration strength of the device. |
Inherited constants |
|---|
android.os.Parcelable
|
Fields | |
|---|---|
public
static
final
Creator<VibrationEffect> |
CREATOR
|
Public methods | |
|---|---|
static
VibrationEffect
|
createOneShot(long milliseconds, int amplitude)
Create a one shot vibration. |
static
VibrationEffect
|
createWaveform(long[] timings, int[] amplitudes, int repeat)
Create a waveform vibration. |
static
VibrationEffect
|
createWaveform(long[] timings, int repeat)
Create a waveform vibration. |
int
|
describeContents()
Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. |
Inherited methods | |
|---|---|
java.lang.Object
| |
android.os.Parcelable
| |
Constants
DEFAULT_AMPLITUDE
int DEFAULT_AMPLITUDE
The default vibration strength of the device.
Constant Value: -1 (0xffffffff)
Fields
Public methods
createOneShot
VibrationEffect createOneShot (long milliseconds, int amplitude)
Create a one shot vibration. One shot vibrations will vibrate constantly for the specified period of time at the specified amplitude, and then stop.
| Parameters | |
|---|---|
milliseconds |
long: The number of milliseconds to vibrate. This must be a positive number. |
amplitude |
int: The strength of the vibration. This must be a value between 1 and 255, or
DEFAULT_AMPLITUDE. |
| Returns | |
|---|---|
VibrationEffect |
The desired effect. |
createWaveform
VibrationEffect createWaveform (long[] timings, int[] amplitudes, int repeat)
Create a waveform vibration. Waveform vibrations are a potentially repeating series of timing and amplitude pairs. For each pair, the value in the amplitude array determines the strength of the vibration and the value in the timing array determines how long it vibrates for. An amplitude of 0 implies no vibration (i.e. off), and any pairs with a timing value of 0 will be ignored.
To cause the pattern to repeat, pass the index into the timings array at which to start the repetition, or -1 to disable repeating.
| Parameters | |
|---|---|
timings |
long: The timing values of the timing / amplitude pairs. Timing values of 0
will cause the pair to be ignored. |
amplitudes |
int: The amplitude values of the timing / amplitude pairs. Amplitude values
must be between 0 and 255, or equal to DEFAULT_AMPLITUDE. An
amplitude value of 0 implies the motor is off. |
repeat |
int: The index into the timings array at which to repeat, or -1 if you you don't
want to repeat. |
| Returns | |
|---|---|
VibrationEffect |
The desired effect. |
createWaveform
VibrationEffect createWaveform (long[] timings, int repeat)
Create a waveform vibration. Waveform vibrations are a potentially repeating series of timing and amplitude pairs. For each pair, the value in the amplitude array determines the strength of the vibration and the value in the timing array determines how long it vibrates for. An amplitude of 0 implies no vibration (i.e. off), and any pairs with a timing value of 0 will be ignored.
The amplitude array of the generated waveform will be the same size as the given
timing array with alternating values of 0 (i.e. off) and DEFAULT_AMPLITUDE,
starting with 0. Therefore the first timing value will be the period to wait before turning
the vibrator on, the second value will be how long to vibrate at DEFAULT_AMPLITUDE
strength, etc.
To cause the pattern to repeat, pass the index into the timings array at which to start the repetition, or -1 to disable repeating.
| Parameters | |
|---|---|
timings |
long: The pattern of alternating on-off timings, starting with off. Timing values
of 0 will cause the timing / amplitude pair to be ignored. |
repeat |
int: The index into the timings array at which to repeat, or -1 if you you don't
want to repeat. |
| Returns | |
|---|---|
VibrationEffect |
The desired effect. |
describeContents
int describeContents ()
Describe the kinds of special objects contained in this Parcelable
instance's marshaled representation. For example, if the object will
include a file descriptor in the output of writeToParcel(Parcel, int),
the return value of this method must include the
CONTENTS_FILE_DESCRIPTOR bit.
| Returns | |
|---|---|
int |
a bitmask indicating the set of special object types marshaled by this Parcelable object instance. |
Interfaces
Classes
- AsyncTask
- BaseBundle
- BatteryManager
- Binder
- Build
- Build.VERSION
- Build.VERSION_CODES
- Bundle
- CancellationSignal
- ConditionVariable
- CountDownTimer
- CpuUsageInfo
- Debug
- Debug.InstructionCount
- Debug.MemoryInfo
- DropBoxManager
- DropBoxManager.Entry
- Environment
- FileObserver
- Handler
- HandlerThread
- HardwarePropertiesManager
- LocaleList
- Looper
- MemoryFile
- Message
- MessageQueue
- Messenger
- Parcel
- ParcelFileDescriptor
- ParcelFileDescriptor.AutoCloseInputStream
- ParcelFileDescriptor.AutoCloseOutputStream
- ParcelUuid
- PatternMatcher
- PersistableBundle
- PowerManager
- PowerManager.WakeLock
- Process
- ProxyFileDescriptorCallback
- RecoverySystem
- RemoteCallbackList
- ResultReceiver
- StatFs
- StrictMode
- StrictMode.ThreadPolicy
- StrictMode.ThreadPolicy.Builder
- StrictMode.VmPolicy
- StrictMode.VmPolicy.Builder
- SystemClock
- TestLooperManager
- TokenWatcher
- Trace
- UserHandle
- UserManager
- VibrationEffect
- Vibrator
- WorkSource
Enums
Exceptions


