Android-specific effects
Trigger platform-specific Android haptics with Haptics.androidHaptics().
Triggers a platform-specific haptic feedback on Android. This method is a no-op on iOS.
Haptics.androidHaptics(type: AndroidHapticsFeedback): Promise<void>Note: Availability of each feedback type varies by Android SDK version. If a requested type is unsupported on the device, it safely falls back to
virtual-key.
AndroidHapticsFeedback type
| Type | Description | Required API |
|---|---|---|
clock-tick | Feedback for a clock tick, e.g., while setting the time. | — |
confirm | Confirms a user's action. | 30+ |
context-click | Feedback for a context-click or right-click. | 23+ |
drag-start | Indicates the start of a drag action. | 34+ |
gesture-end | Indicates the end of a gesture. | 30+ |
gesture-start | Indicates the start of a gesture. | 30+ |
gesture-threshold-activate | Indicates the activation of a gesture threshold. | 34+ |
gesture-threshold-deactivate | Indicates the deactivation of a gesture threshold. | 34+ |
keyboard-press | Feedback for pressing a key on a soft keyboard. | 27+ |
keyboard-release | Feedback for releasing a key on a soft keyboard. | 27+ |
keyboard-tap | Feedback for a tap on a soft keyboard key. | — |
long-press | Feedback for a long press on an object. | — |
no-haptics | Explicitly specifies that no haptic feedback should be provided. | 34+ |
reject | Rejects a user's action. | 30+ |
segment-frequent-tick | A frequent tick in a segmented control. | 34+ |
segment-tick | A tick in a segmented control. | 34+ |
text-handle-move | Feedback for moving a text selection handle. | 27+ |
toggle-off | Indicates a toggle has been turned off. | 34+ |
toggle-on | Indicates a toggle has been turned on. | 34+ |
virtual-key | Feedback for a virtual key press. | — |
virtual-key-release | Feedback for a virtual key release. | 27+ |
Example usage
import {AndroidHapticsFeedback} from '@mhpdev/react-native-haptics';
// Trigger a long press haptic on Android
Haptics.androidHaptics('long-press');
// Trigger a confirm haptic on Android
Haptics.androidHaptics('confirm');androidHaptics triggers haptic feedback through the system view's
performHapticFeedback, so it requires the current activity's view. If there
is no current activity, the call rejects with E_NO_VIEW. Invalid type values
reject with E_INVALID_TYPE.
Behavior details
- The feedback runs on the UI thread so the effect is instant.
- Types above their required API use the matching Android
HapticFeedbackConstantsvalue. - Types below their required API (or otherwise unsupported on the device) fall back to
virtual-keyinstead of failing. - The method is a no-op on iOS — you can call it unconditionally in cross-platform code.