0

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?

Beloo
  • 9,723
  • 7
  • 40
  • 71

1 Answers1

0

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)
}
Beloo
  • 9,723
  • 7
  • 40
  • 71
  • I'm also facing challenges with Samsung devices. And posted my question also. I'm trying to perform haptic feedback without user interaction. Link is here-https://stackoverflow.com/q/71390959/2404262 Any suggestion will be appreciated. – Anshul Tyagi Mar 08 '22 at 08:17
  • @AnshulTyagi Have you tried `KEYBOARD_TAP` haptic type? As i mentioned only few types work on samsung devices – Beloo Mar 09 '22 at 07:58
  • Yeah `KEYBOARD_TAP` works in all devices. – Anshul Tyagi Mar 14 '22 at 03:38