Question

I created an Activity displays an ImageView on the screen. I want get haptic feedback when the image is clicked.

In the main layout main.xml I added the next ImageView tag:

<ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/image"
    android:src="@drawable/dog"
    android:onClick="doBark"
    android:hapticFeedbackEnabled="true"/>

Then, in the Activity code I add this method:

public void doBark(View v) {
        v.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP);
        Log.d("BarkingDog", "is hapticFeedbackEnabled: " + v.isHapticFeedbackEnabled());
}

When I click on the image I can see that doBark() is called and the output of the Logcat says "is hapticFeedbackEnabled: true", but I can't feel anything. I've also tried with the other two HapticFeedback constants, and no luck.

I know that HapticFeedback is enabled because each time I press the menu button, the device vibrates.

Any ideas? Suggestions?

PS: I don't want to use the Vibrator object. By using it, I can make the device vibrate, but I don't think it's the right way to do it.

Was it helpful?

Solution

Take a look at this: http://groups.google.com/group/android-developers/browse_thread/thread/de588e3d15cb9055?pli=1

Do note that it is old though, but the last time I had to use haptic feedback, I followed what Dianne had to say here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top