The goal is to receive vibration feedback during some action happened in app.
HapticFeedbackConstants
has several constants which are responsible for different haptic types.
It is not documented well, but feels logically that CONTEXT_CLICK
fits here. It is not available prior M
, so the code is
fun View.performHapticFeedbackDefault() {
performHapticFeedback(if (VERSION.SDK_INT >= VERSION_CODES.M) {
HapticFeedbackConstants.CONTEXT_CLICK
} else HapticFeedbackConstants.LONG_PRESS)
}
That's working and confirmed on Nexus/Pixel phones, some Huawei etc, but isn't working for Samsung Galaxy phones and we should cover this segment
Seems that Samsung
doesn't have such setting in vibration preferences also
How to perfom haptic feedback on Samsung devices?
Actually i found haptic type which available on Samsung and should be available on other devices - a keyboard haptic.
User is able to disable it from settings, but i think this is the type which covers most of the cases.
fun View.performHapticFeedbackDefault() {
performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP)
}