# HapticFeedbackRequest.Builder

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

# Builder

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/android/os/vibrator/HapticFeedbackRequest.Builder "View this page in Java")  

```
class Builder
```

|---|--------------------------------------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                                                         ||
| ↳ | [android.os.vibrator.HapticFeedbackRequest.Builder](https://developer.android.com/reference/kotlin/android/os/vibrator/HapticFeedbackRequest.Builder#) |

Builder for[HapticFeedbackRequest](https://developer.android.com/reference/kotlin/android/os/vibrator/HapticFeedbackRequest).

## Summary

|                                                                                                                                                                                                                                        Public constructors                                                                                                                                                                                                                                        ||
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [Builder](https://developer.android.com/reference/kotlin/android/os/vibrator/HapticFeedbackRequest.Builder#Builder(android.os.vibrator.HapticFeedbackRequest))`(`request:` `[HapticFeedbackRequest](https://developer.android.com/reference/kotlin/android/os/vibrator/HapticFeedbackRequest)`)` Constructs a builder that is already populated with the fields from a given[HapticFeedbackRequest](https://developer.android.com/reference/kotlin/android/os/vibrator/HapticFeedbackRequest). |
| [Builder](https://developer.android.com/reference/kotlin/android/os/vibrator/HapticFeedbackRequest.Builder#Builder(kotlin.Int))`(`constant:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Constructs a new builder for[HapticFeedbackRequest](https://developer.android.com/reference/kotlin/android/os/vibrator/HapticFeedbackRequest).                                                                                                                     |

|                                                                                                                                                                                                                                                          Public methods                                                                                                                                                                                                                                                           ||
|------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [HapticFeedbackRequest](https://developer.android.com/reference/kotlin/android/os/vibrator/HapticFeedbackRequest)                  | [build](https://developer.android.com/reference/kotlin/android/os/vibrator/HapticFeedbackRequest.Builder#build())`()` Builds a new[HapticFeedbackRequest](https://developer.android.com/reference/kotlin/android/os/vibrator/HapticFeedbackRequest)from this builder object.                                                                                                                  |
| [HapticFeedbackRequest.Builder](https://developer.android.com/reference/kotlin/android/os/vibrator/HapticFeedbackRequest.Builder#) | [setFlags](https://developer.android.com/reference/kotlin/android/os/vibrator/HapticFeedbackRequest.Builder#setFlags(kotlin.Int))`(`flags:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Sets the[HapticFeedbackConstants](https://developer.android.com/reference/kotlin/android/view/HapticFeedbackConstants.html#)flags for the haptic feedback request. |
| [HapticFeedbackRequest.Builder](https://developer.android.com/reference/kotlin/android/os/vibrator/HapticFeedbackRequest.Builder#) | [setUsage](https://developer.android.com/reference/kotlin/android/os/vibrator/HapticFeedbackRequest.Builder#setUsage(kotlin.Int))`(`usage:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Sets the[VibrationAttributes](https://developer.android.com/reference/kotlin/android/os/VibrationAttributes.html#)usage for the haptic feedback request.           |

## Public constructors

### Builder

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

```
Builder(request: HapticFeedbackRequest)
```

Constructs a builder that is already populated with the fields from a given[HapticFeedbackRequest](https://developer.android.com/reference/kotlin/android/os/vibrator/HapticFeedbackRequest).

|                                                                                             Parameters                                                                                             ||
|-----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `request` | [HapticFeedbackRequest](https://developer.android.com/reference/kotlin/android/os/vibrator/HapticFeedbackRequest):the request to create a new builder from. This value cannot be`null`. |

### Builder

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

```
Builder(constant: Int)
```

Constructs a new builder for[HapticFeedbackRequest](https://developer.android.com/reference/kotlin/android/os/vibrator/HapticFeedbackRequest).

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           Parameters                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           ||
|------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `constant` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):the haptic feedback constant for[HapticFeedbackRequest](https://developer.android.com/reference/kotlin/android/os/vibrator/HapticFeedbackRequest)that will be constructed from the builder. This needs to be one of the constants defined in[HapticFeedbackConstants](https://developer.android.com/reference/kotlin/android/view/HapticFeedbackConstants.html#). Value is[android.view.HapticFeedbackConstants#NO_HAPTICS](https://developer.android.com/reference/kotlin/android/view/HapticFeedbackConstants.html#NO_HAPTICS:kotlin.Int),[android.view.HapticFeedbackConstants#LONG_PRESS](https://developer.android.com/reference/kotlin/android/view/HapticFeedbackConstants.html#LONG_PRESS:kotlin.Int),[android.view.HapticFeedbackConstants#VIRTUAL_KEY](https://developer.android.com/reference/kotlin/android/view/HapticFeedbackConstants.html#VIRTUAL_KEY:kotlin.Int),[android.view.HapticFeedbackConstants#KEYBOARD_TAP](https://developer.android.com/reference/kotlin/android/view/HapticFeedbackConstants.html#KEYBOARD_TAP:kotlin.Int),[android.view.HapticFeedbackConstants#CLOCK_TICK](https://developer.android.com/reference/kotlin/android/view/HapticFeedbackConstants.html#CLOCK_TICK:kotlin.Int), android.view.HapticFeedbackConstants.CALENDAR_DATE,[android.view.HapticFeedbackConstants#CONTEXT_CLICK](https://developer.android.com/reference/kotlin/android/view/HapticFeedbackConstants.html#CONTEXT_CLICK:kotlin.Int),[android.view.HapticFeedbackConstants#KEYBOARD_RELEASE](https://developer.android.com/reference/kotlin/android/view/HapticFeedbackConstants.html#KEYBOARD_RELEASE:kotlin.Int),[android.view.HapticFeedbackConstants#VIRTUAL_KEY_RELEASE](https://developer.android.com/reference/kotlin/android/view/HapticFeedbackConstants.html#VIRTUAL_KEY_RELEASE:kotlin.Int),[android.view.HapticFeedbackConstants#TEXT_HANDLE_MOVE](https://developer.android.com/reference/kotlin/android/view/HapticFeedbackConstants.html#TEXT_HANDLE_MOVE:kotlin.Int), android.view.HapticFeedbackConstants.DRAG_CROSSING,[android.view.HapticFeedbackConstants#GESTURE_START](https://developer.android.com/reference/kotlin/android/view/HapticFeedbackConstants.html#GESTURE_START:kotlin.Int),[android.view.HapticFeedbackConstants#GESTURE_END](https://developer.android.com/reference/kotlin/android/view/HapticFeedbackConstants.html#GESTURE_END:kotlin.Int), android.view.HapticFeedbackConstants.EDGE_SQUEEZE, android.view.HapticFeedbackConstants.EDGE_RELEASE,[android.view.HapticFeedbackConstants#CONFIRM](https://developer.android.com/reference/kotlin/android/view/HapticFeedbackConstants.html#CONFIRM:kotlin.Int),[android.view.HapticFeedbackConstants#REJECT](https://developer.android.com/reference/kotlin/android/view/HapticFeedbackConstants.html#REJECT:kotlin.Int), android.view.HapticFeedbackConstants.SCROLL_TICK, android.view.HapticFeedbackConstants.SCROLL_ITEM_FOCUS, android.view.HapticFeedbackConstants.SCROLL_LIMIT,[android.view.HapticFeedbackConstants#TOGGLE_ON](https://developer.android.com/reference/kotlin/android/view/HapticFeedbackConstants.html#TOGGLE_ON:kotlin.Int),[android.view.HapticFeedbackConstants#TOGGLE_OFF](https://developer.android.com/reference/kotlin/android/view/HapticFeedbackConstants.html#TOGGLE_OFF:kotlin.Int),[android.view.HapticFeedbackConstants#GESTURE_THRESHOLD_ACTIVATE](https://developer.android.com/reference/kotlin/android/view/HapticFeedbackConstants.html#GESTURE_THRESHOLD_ACTIVATE:kotlin.Int),[android.view.HapticFeedbackConstants#GESTURE_THRESHOLD_DEACTIVATE](https://developer.android.com/reference/kotlin/android/view/HapticFeedbackConstants.html#GESTURE_THRESHOLD_DEACTIVATE:kotlin.Int),[android.view.HapticFeedbackConstants#DRAG_START](https://developer.android.com/reference/kotlin/android/view/HapticFeedbackConstants.html#DRAG_START:kotlin.Int),[android.view.HapticFeedbackConstants#SEGMENT_TICK](https://developer.android.com/reference/kotlin/android/view/HapticFeedbackConstants.html#SEGMENT_TICK:kotlin.Int),[android.view.HapticFeedbackConstants#SEGMENT_FREQUENT_TICK](https://developer.android.com/reference/kotlin/android/view/HapticFeedbackConstants.html#SEGMENT_FREQUENT_TICK:kotlin.Int), android.view.HapticFeedbackConstants.SAFE_MODE_ENABLED, android.view.HapticFeedbackConstants.ASSISTANT_BUTTON, android.view.HapticFeedbackConstants.LONG_PRESS_POWER_BUTTON, android.view.HapticFeedbackConstants.BIOMETRIC_CONFIRM, or android.view.HapticFeedbackConstants.BIOMETRIC_REJECT |

## Public methods

### build

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

```
fun build(): HapticFeedbackRequest
```

Builds a new[HapticFeedbackRequest](https://developer.android.com/reference/kotlin/android/os/vibrator/HapticFeedbackRequest)from this builder object.

|                                                                     Return                                                                     ||
|-------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [HapticFeedbackRequest](https://developer.android.com/reference/kotlin/android/os/vibrator/HapticFeedbackRequest) | This value cannot be`null`. |

### setFlags

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

```
fun setFlags(flags: Int): HapticFeedbackRequest.Builder
```

Sets the[HapticFeedbackConstants](https://developer.android.com/reference/kotlin/android/view/HapticFeedbackConstants.html#)flags for the haptic feedback request.

|                                                                                                                                                                                                                                                          Parameters                                                                                                                                                                                                                                                          ||
|---------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `flags` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):Value is either`0`or a combination of[android.view.HapticFeedbackConstants#FLAG_IGNORE_VIEW_SETTING](https://developer.android.com/reference/kotlin/android/view/HapticFeedbackConstants.html#FLAG_IGNORE_VIEW_SETTING:kotlin.Int), and[android.view.HapticFeedbackConstants#FLAG_IGNORE_GLOBAL_SETTING](https://developer.android.com/reference/kotlin/android/view/HapticFeedbackConstants.html#FLAG_IGNORE_GLOBAL_SETTING:kotlin.Int) |

|                                                                             Return                                                                              ||
|------------------------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [HapticFeedbackRequest.Builder](https://developer.android.com/reference/kotlin/android/os/vibrator/HapticFeedbackRequest.Builder#) | This value cannot be`null`. |

### setUsage

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

```
fun setUsage(usage: Int): HapticFeedbackRequest.Builder
```

Sets the[VibrationAttributes](https://developer.android.com/reference/kotlin/android/os/VibrationAttributes.html#)usage for the haptic feedback request.

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             Parameters                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              ||
|---------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `usage` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):Value is[android.os.VibrationAttributes#USAGE_UNKNOWN](https://developer.android.com/reference/kotlin/android/os/VibrationAttributes.html#USAGE_UNKNOWN:kotlin.Int),[android.os.VibrationAttributes#USAGE_ACCESSIBILITY](https://developer.android.com/reference/kotlin/android/os/VibrationAttributes.html#USAGE_ACCESSIBILITY:kotlin.Int),[android.os.VibrationAttributes#USAGE_ALARM](https://developer.android.com/reference/kotlin/android/os/VibrationAttributes.html#USAGE_ALARM:kotlin.Int),[android.os.VibrationAttributes#USAGE_COMMUNICATION_REQUEST](https://developer.android.com/reference/kotlin/android/os/VibrationAttributes.html#USAGE_COMMUNICATION_REQUEST:kotlin.Int),[android.os.VibrationAttributes#USAGE_HARDWARE_FEEDBACK](https://developer.android.com/reference/kotlin/android/os/VibrationAttributes.html#USAGE_HARDWARE_FEEDBACK:kotlin.Int),[android.os.VibrationAttributes#USAGE_MEDIA](https://developer.android.com/reference/kotlin/android/os/VibrationAttributes.html#USAGE_MEDIA:kotlin.Int),[android.os.VibrationAttributes#USAGE_NOTIFICATION](https://developer.android.com/reference/kotlin/android/os/VibrationAttributes.html#USAGE_NOTIFICATION:kotlin.Int),[android.os.VibrationAttributes#USAGE_PHYSICAL_EMULATION](https://developer.android.com/reference/kotlin/android/os/VibrationAttributes.html#USAGE_PHYSICAL_EMULATION:kotlin.Int),[android.os.VibrationAttributes#USAGE_RINGTONE](https://developer.android.com/reference/kotlin/android/os/VibrationAttributes.html#USAGE_RINGTONE:kotlin.Int),[android.os.VibrationAttributes#USAGE_TOUCH](https://developer.android.com/reference/kotlin/android/os/VibrationAttributes.html#USAGE_TOUCH:kotlin.Int), android.os.VibrationAttributes.USAGE_IME_FEEDBACK, or[android.os.VibrationAttributes#USAGE_GESTURE_INPUT](https://developer.android.com/reference/kotlin/android/os/VibrationAttributes.html#USAGE_GESTURE_INPUT:kotlin.Int) |

|                                                                             Return                                                                              ||
|------------------------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [HapticFeedbackRequest.Builder](https://developer.android.com/reference/kotlin/android/os/vibrator/HapticFeedbackRequest.Builder#) | This value cannot be`null`. |

**See Also**

- [android.os.VibrationAttributes#getUsage](https://developer.android.com/reference/kotlin/android/os/VibrationAttributes.html#getUsage())