Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Ctors](https://developer.android.com/reference/android/os/VibrationAttributes.Builder#pubctors) \| [Methods](https://developer.android.com/reference/android/os/VibrationAttributes.Builder#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/os/VibrationAttributes.Builder#inhmethods)

# VibrationAttributes.Builder

*** ** * ** ***


`
public
static
final

class
VibrationAttributes.Builder
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


`

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.os.VibrationAttributes.Builder |

<br />

*** ** * ** ***

Builder class for `https://developer.android.com/reference/android/os/VibrationAttributes` objects.
By default, all information is set to UNKNOWN.

## Summary

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/os/VibrationAttributes.Builder#Builder()() ` Constructs a new Builder with the defaults. |
| ` https://developer.android.com/reference/android/os/VibrationAttributes.Builder#Builder(android.media.AudioAttributes)(https://developer.android.com/reference/android/media/AudioAttributes audio) ` Constructs a new Builder from AudioAttributes. |
| ` https://developer.android.com/reference/android/os/VibrationAttributes.Builder#Builder(android.os.VibrationAttributes)(https://developer.android.com/reference/android/os/VibrationAttributes vib) ` Constructs a new Builder from a given VibrationAttributes. |

| ### Public methods ||
|---|---|
| ` https://developer.android.com/reference/android/os/VibrationAttributes` | ` https://developer.android.com/reference/android/os/VibrationAttributes.Builder#build()() ` Combines all of the attributes that have been set and returns a new `https://developer.android.com/reference/android/os/VibrationAttributes` object. |
| ` https://developer.android.com/reference/android/os/VibrationAttributes.Builder` | ` https://developer.android.com/reference/android/os/VibrationAttributes.Builder#setFlags(int,%20int)(int flags, int mask) ` Sets only the flags specified in the bitmask, leaving the other supported flag values unchanged in the builder. |
| ` https://developer.android.com/reference/android/os/VibrationAttributes.Builder` | ` https://developer.android.com/reference/android/os/VibrationAttributes.Builder#setUsage(int)(int usage) ` Sets the attribute describing the type of the corresponding vibration. |

| ### Inherited methods |
|---|---|
| From class ` https://developer.android.com/reference/java/lang/Object ` |---|---| | ` https://developer.android.com/reference/java/lang/Object` | ` https://developer.android.com/reference/java/lang/Object#clone()() ` Creates and returns a copy of this object. | | ` boolean` | ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` Indicates whether some other object is "equal to" this one. | | ` void` | ` https://developer.android.com/reference/java/lang/Object#finalize()() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. | | ` final https://developer.android.com/reference/java/lang/Class<?>` | ` https://developer.android.com/reference/java/lang/Object#getClass()() ` Returns the runtime class of this `Object`. | | ` int` | ` https://developer.android.com/reference/java/lang/Object#hashCode()() ` Returns a hash code value for the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notify()() ` Wakes up a single thread that is waiting on this object's monitor. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notifyAll()() ` Wakes up all threads that are waiting on this object's monitor. | | ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/lang/Object#toString()() ` Returns a string representation of the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(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` | ` https://developer.android.com/reference/java/lang/Object#wait(long)(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` | ` https://developer.android.com/reference/java/lang/Object#wait()() ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*. | ||

## Public constructors

### Builder

Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Builder ()
```

Constructs a new Builder with the defaults.

<br />

### Builder

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Builder (AudioAttributes audio)
```

Constructs a new Builder from AudioAttributes.

<br />

| Parameters ||
|---|---|
| `audio` | `AudioAttributes`: This value cannot be `null`. <br /> |

### Builder

Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Builder (VibrationAttributes vib)
```

Constructs a new Builder from a given VibrationAttributes.

<br />

| Parameters ||
|---|---|
| `vib` | `VibrationAttributes`: This value may be `null`. <br /> |

## Public methods

### build

Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public VibrationAttributes build ()
```

Combines all of the attributes that have been set and returns a new
`https://developer.android.com/reference/android/os/VibrationAttributes` object.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/os/VibrationAttributes` | a new `https://developer.android.com/reference/android/os/VibrationAttributes` object. This value cannot be `null`. <br /> |

### setFlags

Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public VibrationAttributes.Builder setFlags (int flags, 
                int mask)
```

Sets only the flags specified in the bitmask, leaving the other supported flag values
unchanged in the builder.

<br />

| Parameters ||
|---|---|
| `flags` | `int`: Combination of flags to be set. Value is either `0` or a combination of the following: - `https://developer.android.com/reference/android/os/VibrationAttributes#FLAG_BYPASS_INTERRUPTION_POLICY` |
| `mask` | `int`: Bit range that should be changed. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/os/VibrationAttributes.Builder` | the same Builder instance. This value cannot be `null`. <br /> |

### setUsage

Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public VibrationAttributes.Builder setUsage (int usage)
```

Sets the attribute describing the type of the corresponding vibration.

<br />

| Parameters ||
|---|---|
| `usage` | `int`: The type of usage for the vibration. Value is one of the following: - `https://developer.android.com/reference/android/os/VibrationAttributes#USAGE_UNKNOWN` - `https://developer.android.com/reference/android/os/VibrationAttributes#USAGE_ACCESSIBILITY` - `https://developer.android.com/reference/android/os/VibrationAttributes#USAGE_ALARM` - `https://developer.android.com/reference/android/os/VibrationAttributes#USAGE_COMMUNICATION_REQUEST` - `https://developer.android.com/reference/android/os/VibrationAttributes#USAGE_HARDWARE_FEEDBACK` - `https://developer.android.com/reference/android/os/VibrationAttributes#USAGE_MEDIA` - `https://developer.android.com/reference/android/os/VibrationAttributes#USAGE_NOTIFICATION` - `https://developer.android.com/reference/android/os/VibrationAttributes#USAGE_PHYSICAL_EMULATION` - `https://developer.android.com/reference/android/os/VibrationAttributes#USAGE_RINGTONE` - `https://developer.android.com/reference/android/os/VibrationAttributes#USAGE_TOUCH` - `https://developer.android.com/reference/android/os/VibrationAttributes#USAGE_GESTURE_INPUT` |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/os/VibrationAttributes.Builder` | the same Builder instance. This value cannot be `null`. <br /> |