Thanks Lee and Dianne.

That works fine, although the vibrate is noticeably lower than that when you
type using Hero keyboard. Still, it works fine.

I was debating about leaving it in the OnClickListener(), as that sort of
seemed more appropriate, it would be a notification that you had clicked the
button, but on second thoughts it is supposed to let you know you have
actually touched the screen, so the I'm now calling it in the ACTION_DOWN
event caught by OnTouch(). This now emulates the feedback behaviour of the
Hero soft keyboard.

Dianne, I appreciate the UI consideration and have indeed made it optional.

However, the docs say that although they only provide built in actions for
the long press, it can be used for your own widgets also, so is adding it to
my own UI button presses really such a bad thing?

In my case I have some purely icon like image buttons, which have
transparent backgrounds and blend nicely in to the screen background, so
they dont look like normal grey buttons. I have already given them some nice
images dependent on the pressed/focused/unpressed state, so it is clear that
they are pressable buttons, the haptic is just icing on the cake really.

Regards
James


2009/9/29 Dianne Hackborn <[email protected]>

> Currently there is only a definition for long press, so this API isn't all
> that useful.  (This is also why the preference is hidden away in SpareParts,
> it's not really ready for prime time.)  If you are giving feedback for a
> long press, then you may want to use it...  but if you also feel the need to
> have it ignore the preference, then please consider having your own
> preference in your app since some users really dislike this stuff.
>
>
> On Mon, Sep 28, 2009 at 8:44 AM, Lee <[email protected]> wrote:
>
>>
>> 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 <[email protected]> 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?
>>
>>
>
>
> --
> Dianne Hackborn
> Android framework engineer
> [email protected]
>
> Note: please don't send private questions to me, as I don't have time to
> provide private support, and so won't reply to such e-mails.  All such
> questions should be posted on public forums, where I and others can see and
> answer them.
>
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to