This one works for me: performHapticFeedback( HapticFeedbackConstants.LONG_PRESS, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING );
I remember having trouble getting other things to work. Fortunately I only use Haptic Feedback with a long press, otherwise the Code Cops might come calling. If really want to be hauled in front of a judge you can use the Vibrator service directly. Lee On Sep 28, 2:33 pm, James W <jpbwebs...@gmail.com> wrote: > I want to invoke the haptic feedback buzz when my ImageButton is > pressed, but I am not sure the best way to do it. I first checked that > my button was enabled for that, and isHapticFeedbackEnabled() returns > true. > > Then I am calling performHapticFeedback() with the constant > FLAG_IGNORE_GLOBAL_SETTING, as the docs indicate that will be used to > override any global settings. > > The doc is a little ambiguous, but it does imply that this is > something I can call at any time, so I am calling it in the > OnClickListener(): > > final ImageButton mybutton= (ImageButton) findViewById > (R.id.mybutton); > mybutton.setOnClickListener(new View.OnClickListener() > { > public void onClick(View v) > { > mybutton.performHapticFeedback > (HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); > // The rest of my code > } > } > ); > > I appreciate that it would be better to call it when the finger first > touches the button rather than on the Click event, but I wanted to get > it working to start with, before refining it. > > Am I barking completely up the wrong tree, or should the above work > when I click on the button, because nothing happens? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---