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.Builder
Builder class for |
Constants | |
---|---|
int |
FLAG_BYPASS_INTERRUPTION_POLICY
Flag requesting vibration effect to be played even under limited interruptions. |
int |
USAGE_ACCESSIBILITY
Usage value to use for accessibility vibrations, such as with a screen reader. |
int |
USAGE_ALARM
Usage value to use for alarm vibrations. |
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. |
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. |
int |
USAGE_CLASS_MASK
Mask for vibration usage class value. |
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. |
int |
USAGE_CLASS_UNKNOWN
Vibration usage class value to use when the vibration usage class is unknown. |
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. |
int |
USAGE_HARDWARE_FEEDBACK
Usage value to use for vibrations which provide a feedback for hardware component interaction, such as a fingerprint sensor. |
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. |
int |
USAGE_NOTIFICATION
Usage value to use for notification vibrations. |
int |
USAGE_PHYSICAL_EMULATION
Usage value to use for vibrations which emulate physical hardware reactions, such as edge squeeze. |
int |
USAGE_RINGTONE
Usage value to use for ringtone vibrations. |
int |
USAGE_TOUCH
Usage value to use for touch vibrations. |
int |
USAGE_UNKNOWN
Usage 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_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 is USAGE_UNKNOWN , USAGE_ACCESSIBILITY , USAGE_ALARM , USAGE_COMMUNICATION_REQUEST , USAGE_HARDWARE_FEEDBACK , USAGE_MEDIA , USAGE_NOTIFICATION , USAGE_PHYSICAL_EMULATION , USAGE_RINGTONE , USAGE_TOUCH , or android.os.VibrationAttributes.USAGE_IME_FEEDBACK |
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 0 or CONTENTS_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
x
andy
,x.equals(y)
should returntrue
if and only ify.equals(x)
returnstrue
. - It is transitive: for any non-null reference values
x
,y
, andz
, ifx.equals(y)
returnstrue
andy.equals(z)
returnstrue
, thenx.equals(z)
should returntrue
. - It is consistent: for any non-null reference values
x
andy
, multiple invocations ofx.equals(y)
consistently returntrue
or consistently returnfalse
, provided no information used inequals
comparisons 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 be null . |
Returns | |
---|---|
boolean |
true if this object is the same as the obj
argument; false otherwise. |
getFlags
public int getFlags ()
Return the flags.
Returns | |
---|---|
int |
a combined mask of all flags
Value is either 0 or a combination of FLAG_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 , or android.os.VibrationAttributes.USAGE_IME_FEEDBACK |
getUsageClass
public int getUsageClass ()
Return the vibration usage class.
Returns | |
---|---|
int |
Value is USAGE_CLASS_UNKNOWN , USAGE_CLASS_ALARM , USAGE_CLASS_FEEDBACK , or USAGE_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
hashCode
method must consistently return the same integer, provided no information used inequals
comparisons 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
equals
method, then calling thehashCode
method 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
equals
method, then calling thehashCode
method 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 either 0 or a combination of FLAG_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 be null . |
flags |
int : Additional flags about how the object should be written.
May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE .
Value is either 0 or a combination of Parcelable.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 2024-12-18 UTC.