Android: Haptic feedback: onClick() event vs hapticFeedbackEnabled in the view

Posted by dreeves on Stack Overflow See other posts from Stack Overflow or by dreeves
Published on 2010-05-13T20:23:39Z Indexed on 2010/05/14 1:24 UTC
Read the original article Hit count: 1262

Filed under:
|

If you want a button to provide haptic feedback (ie, the phone vibrates very briefly so you can feel that you really pushed the button), what's the standard way to do that? It seems you can either explicitly set an onClick() event and call the vibrate() function, giving a number of milliseconds to vibrate, or you can set hapticFeedbackEnabled in the view.

The documentation seems to indicate that the latter only works for long-presses or virtual on-screen keys: http://developer.android.com/reference/android/view/View.html#performHapticFeedback(int)

If that's right, then I need to either make my button a virtual on-screen key or manually set the onClick() event.

What do you recommend?

Also, if I want the vibrating to happen immediately when the user's finger touches the button, as opposed to when their finger "releases" the button, what's the best way to accomplish that?

Related question: http://stackoverflow.com/questions/2228151/how-to-enable-haptic-feedback-on-button-view

© Stack Overflow or respective owner

Related posts about android

Related posts about java