Is there a way to disable the vibration for the OnLongClick event?
I want no vibration or if enabled a custom vibration.
EDIT: Thank you that did it!
Sure. If you look in the base View
class, there are several options for haptic feedback, such as:
A boolean XML attribute: android:hapticFeedbackEnabled
and its related Java method: setHapticFeedbackEnabled(boolean)
There are other related methods such as performHapticFeedback()
that you can call, but if you've disabled haptic feedback in the View, you'll have to pass a flag to override the View's setting, and perform it anyway. There are some constants you can pass, located in HapticFeedbackConstants
, to get different vibration patterns from the system. To do a custom one, you'd have to override your onLongClick method and get an instance of the VIBRATOR service and have it perform a custom vibration pattern from there.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With