VibrationAttributes
  public
  
  final
  
  class
  VibrationAttributes
  
    extends Object
  
  
  
  
  
      implements
      
        Parcelable
      
  
  
| java.lang.Object | |
| ↳ | android.os.VibrationAttributes | 
Encapsulates a collection of attributes describing information about a vibration.
Summary
| Nested classes | |
|---|---|
| 
        
        
        
        
        class | VibrationAttributes.BuilderBuilder class for  | 
| Constants | |
|---|---|
| int | FLAG_BYPASS_INTERRUPTION_POLICYFlag requesting vibration effect to be played even under limited interruptions. | 
| int | USAGE_ACCESSIBILITYUsage value to use for accessibility vibrations, such as with a screen reader. | 
| int | USAGE_ALARMUsage value to use for alarm vibrations. | 
| int | USAGE_CLASS_ALARMVibration usage class value to use when the vibration is initiated to catch user's attention, such as alarm, ringtone, and notification vibrations. | 
| int | USAGE_CLASS_FEEDBACKVibration usage class value to use when the vibration is initiated as a response to user's actions, such as emulation of physical effects, and texting feedback vibration. | 
| int | USAGE_CLASS_MASKMask for vibration usage class value. | 
| int | USAGE_CLASS_MEDIAVibration usage class value to use when the vibration is part of media, such as music, movie, soundtrack, game or animations. | 
| int | USAGE_CLASS_UNKNOWNVibration usage class value to use when the vibration usage class is unknown. | 
| int | USAGE_COMMUNICATION_REQUESTUsage value to use for vibrations which mean a request to enter/end a communication with the user, such as a voice prompt. | 
| int | USAGE_GESTURE_INPUTUsage value to use for vibrations performed as feedback for a user's gesture input. | 
| int | USAGE_HARDWARE_FEEDBACKUsage value to use for vibrations which provide a feedback for hardware component interaction, such as a fingerprint sensor. | 
| int | USAGE_MEDIAUsage value to use for media vibrations, such as music, movie, soundtrack, animations, games, or any interactive media that isn't for touch feedback specifically. | 
| int | USAGE_NOTIFICATIONUsage value to use for notification vibrations. | 
| int | USAGE_PHYSICAL_EMULATIONUsage value to use for vibrations which emulate physical hardware reactions, such as edge squeeze. | 
| int | USAGE_RINGTONEUsage value to use for ringtone vibrations. | 
| int | USAGE_TOUCHUsage value to use for touch vibrations. | 
| int | USAGE_UNKNOWNUsage value to use when usage is unknown. | 
| Inherited constants | 
|---|
| Fields | |
|---|---|
| 
    public
    static
    final
    Creator<VibrationAttributes> | CREATOR
 | 
| Public methods | |
|---|---|
| 
        
        
        static
        
        
        VibrationAttributes | 
      createForUsage(int usage)
      Creates a new  | 
| 
        
        
        
        
        
        int | 
      describeContents()
      Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. | 
| 
        
        
        
        
        
        boolean | 
      equals(Object o)
      Indicates whether some other object is "equal to" this one. | 
| 
        
        
        
        
        
        int | 
      getFlags()
      Return the flags. | 
| 
        
        
        
        
        
        int | 
      getUsage()
      Return the vibration usage. | 
| 
        
        
        
        
        
        int | 
      getUsageClass()
      Return the vibration usage class. | 
| 
        
        
        
        
        
        int | 
      hashCode()
      Returns a hash code value for the object. | 
| 
        
        
        
        
        
        boolean | 
      isFlagSet(int flag)
      Check whether a flag is set | 
| 
        
        
        
        
        
        String | 
      toString()
      Returns a string representation of the object. | 
| 
        
        
        
        
        
        void | 
      writeToParcel(Parcel dest, int flags)
      Flatten this object in to a Parcel. | 
| Inherited methods | |
|---|---|
Constants
FLAG_BYPASS_INTERRUPTION_POLICY
public static final int FLAG_BYPASS_INTERRUPTION_POLICY
Flag requesting vibration effect to be played even under limited interruptions.
Only privileged apps can ignore user settings that limit interruptions, and this flag will be ignored otherwise.
Constant Value: 1 (0x00000001)
USAGE_ACCESSIBILITY
public static final int USAGE_ACCESSIBILITY
Usage value to use for accessibility vibrations, such as with a screen reader.
Constant Value: 66 (0x00000042)
USAGE_ALARM
public static final int USAGE_ALARM
Usage value to use for alarm vibrations.
Constant Value: 17 (0x00000011)
USAGE_CLASS_ALARM
public static final int USAGE_CLASS_ALARM
Vibration usage class value to use when the vibration is initiated to catch user's attention, such as alarm, ringtone, and notification vibrations.
Constant Value: 1 (0x00000001)
USAGE_CLASS_FEEDBACK
public static final int USAGE_CLASS_FEEDBACK
Vibration usage class value to use when the vibration is initiated as a response to user's actions, such as emulation of physical effects, and texting feedback vibration.
Constant Value: 2 (0x00000002)
USAGE_CLASS_MASK
public static final int USAGE_CLASS_MASK
Mask for vibration usage class value.
Constant Value: 15 (0x0000000f)
USAGE_CLASS_MEDIA
public static final int USAGE_CLASS_MEDIA
Vibration usage class value to use when the vibration is part of media, such as music, movie, soundtrack, game or animations.
Constant Value: 3 (0x00000003)
USAGE_CLASS_UNKNOWN
public static final int USAGE_CLASS_UNKNOWN
Vibration usage class value to use when the vibration usage class is unknown.
Constant Value: 0 (0x00000000)
USAGE_COMMUNICATION_REQUEST
public static final int USAGE_COMMUNICATION_REQUEST
Usage value to use for vibrations which mean a request to enter/end a communication with the user, such as a voice prompt.
Constant Value: 65 (0x00000041)
USAGE_GESTURE_INPUT
public static final int USAGE_GESTURE_INPUT
Usage value to use for vibrations performed as feedback for a user's gesture input.
A gesture input is broadly defined as a user input that falls outside the direct
 usage of a physical ERROR(/InputDevice). Note that the gesture input may involve interacting
 with an ERROR(/InputDevice), but the input itself is a user gesture that is not a direct
 application of the ERROR(/InputDevice).
 
The exact definition of a gesture input varies across form-factors and input modalities.
 For example, on Wearable devices, it could be a hand-based gesture provided by the user
 without touching any physical ERROR(/InputDevice). Another example is a pinch gesture on a
 touchscreen.
Constant Value: 98 (0x00000062)
USAGE_HARDWARE_FEEDBACK
public static final int USAGE_HARDWARE_FEEDBACK
Usage value to use for vibrations which provide a feedback for hardware component interaction, such as a fingerprint sensor.
Constant Value: 50 (0x00000032)
USAGE_MEDIA
public static final int USAGE_MEDIA
Usage value to use for media vibrations, such as music, movie, soundtrack, animations, games, or any interactive media that isn't for touch feedback specifically.
Constant Value: 19 (0x00000013)
USAGE_NOTIFICATION
public static final int USAGE_NOTIFICATION
Usage value to use for notification vibrations.
Constant Value: 49 (0x00000031)
USAGE_PHYSICAL_EMULATION
public static final int USAGE_PHYSICAL_EMULATION
Usage value to use for vibrations which emulate physical hardware reactions, such as edge squeeze.
Note that normal screen-touch feedback "click" effects would typically be
 classed as USAGE_TOUCH, and that on-screen "physical" animations
 like bouncing would be USAGE_MEDIA.
Constant Value: 34 (0x00000022)
USAGE_RINGTONE
public static final int USAGE_RINGTONE
Usage value to use for ringtone vibrations.
Constant Value: 33 (0x00000021)
USAGE_TOUCH
public static final int USAGE_TOUCH
Usage value to use for touch vibrations.
Most typical haptic feedback should be classed as touch feedback. Examples include vibrations for tap, long press, drag and scroll.
Constant Value: 18 (0x00000012)
USAGE_UNKNOWN
public static final int USAGE_UNKNOWN
Usage value to use when usage is unknown.
Constant Value: 0 (0x00000000)
Fields
Public methods
createForUsage
public static VibrationAttributes createForUsage (int usage)
Creates a new VibrationAttributes instance with given usage.
| Parameters | |
|---|---|
| usage | int: Value isUSAGE_UNKNOWN,USAGE_ACCESSIBILITY,USAGE_ALARM,USAGE_COMMUNICATION_REQUEST,USAGE_HARDWARE_FEEDBACK,USAGE_MEDIA,USAGE_NOTIFICATION,USAGE_PHYSICAL_EMULATION,USAGE_RINGTONE,USAGE_TOUCH, android.os.VibrationAttributes.USAGE_IME_FEEDBACK, orUSAGE_GESTURE_INPUT | 
| Returns | |
|---|---|
| VibrationAttributes | This value cannot be null. | 
describeContents
public 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(android.os.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.
 Value is either 0orCONTENTS_FILE_DESCRIPTOR | 
equals
public boolean equals (Object o)
Indicates whether some other object is "equal to" this one.
 The equals method implements an equivalence relation
 on non-null object references:
 
- It is reflexive: for any non-null reference value
     x,x.equals(x)should returntrue.
- It is symmetric: for any non-null reference values
     xandy,x.equals(y)should returntrueif and only ify.equals(x)returnstrue.
- It is transitive: for any non-null reference values
     x,y, andz, ifx.equals(y)returnstrueandy.equals(z)returnstrue, thenx.equals(z)should returntrue.
- It is consistent: for any non-null reference values
     xandy, multiple invocations ofx.equals(y)consistently returntrueor consistently returnfalse, provided no information used inequalscomparisons on the objects is modified.
- For any non-null reference value x,x.equals(null)should returnfalse.
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.
| Parameters | |
|---|---|
| o | Object: This value may benull. | 
| Returns | |
|---|---|
| boolean | trueif this object is the same as the obj
          argument;falseotherwise. | 
getFlags
public int getFlags ()
Return the flags.
| Returns | |
|---|---|
| int | a combined mask of all flags
 Value is either 0or a combination ofFLAG_BYPASS_INTERRUPTION_POLICY, android.os.VibrationAttributes.FLAG_BYPASS_USER_VIBRATION_INTENSITY_OFF, android.os.VibrationAttributes.FLAG_INVALIDATE_SETTINGS_CACHE, and android.os.VibrationAttributes.FLAG_PIPELINED_EFFECT | 
getUsage
public int getUsage ()
Return the vibration usage.
| Returns | |
|---|---|
| int | Value is USAGE_UNKNOWN,USAGE_ACCESSIBILITY,USAGE_ALARM,USAGE_COMMUNICATION_REQUEST,USAGE_HARDWARE_FEEDBACK,USAGE_MEDIA,USAGE_NOTIFICATION,USAGE_PHYSICAL_EMULATION,USAGE_RINGTONE,USAGE_TOUCH, android.os.VibrationAttributes.USAGE_IME_FEEDBACK, orUSAGE_GESTURE_INPUT | 
getUsageClass
public int getUsageClass ()
Return the vibration usage class.
| Returns | |
|---|---|
| int | Value is USAGE_CLASS_UNKNOWN,USAGE_CLASS_ALARM,USAGE_CLASS_FEEDBACK, orUSAGE_CLASS_MEDIA | 
hashCode
public int hashCode ()
Returns a hash code value for the object. This method is
 supported for the benefit of hash tables such as those provided by
 HashMap.
 
 The general contract of hashCode is:
 
- Whenever it is invoked on the same object more than once during
     an execution of a Java application, the hashCodemethod must consistently return the same integer, provided no information used inequalscomparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
- If two objects are equal according to the equalsmethod, then calling thehashCodemethod on each of the two objects must produce the same integer result.
- It is not required that if two objects are unequal
     according to the equalsmethod, then calling thehashCodemethod on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
| Returns | |
|---|---|
| int | a hash code value for this object. | 
isFlagSet
public boolean isFlagSet (int flag)
Check whether a flag is set
| Parameters | |
|---|---|
| flag | int: Value is either0or a combination ofFLAG_BYPASS_INTERRUPTION_POLICY, android.os.VibrationAttributes.FLAG_BYPASS_USER_VIBRATION_INTENSITY_OFF, android.os.VibrationAttributes.FLAG_INVALIDATE_SETTINGS_CACHE, and android.os.VibrationAttributes.FLAG_PIPELINED_EFFECT | 
| Returns | |
|---|---|
| boolean | true if a flag is set and false otherwise | 
toString
public String toString ()
Returns a string representation of the object.
| Returns | |
|---|---|
| String | a string representation of the object. | 
writeToParcel
public void writeToParcel (Parcel dest, int flags)
Flatten this object in to a Parcel.
| Parameters | |
|---|---|
| dest | Parcel: This value cannot benull. | 
| flags | int: Additional flags about how the object should be written.
 May be 0 orParcelable.PARCELABLE_WRITE_RETURN_VALUE.
 Value is either0or a combination ofParcelable.PARCELABLE_WRITE_RETURN_VALUE, and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES | 
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-09-17 UTC.
