When a click event is triggered, it is passed down to the lowest handler available (unless someone interrupted). In your case, a long click event is first passed to the OnLongClickListener
. If that listener returns true
, it basically announces that this click event has been handled. If it returns false
, it a announces that the click event was not handled by it, and that's why the event is passed along one level higher to the handler above it in the hierarchy, in your case, the OnClickListener
.
That's why returning false
isn't the way to go, because you do want to handle the long click event.
What about creating a background thread or an ASyncTask
for the vibration itself.
Something Like:
@Override
public boolean onLongClick(View v) {
getHandler().post(new Runnable() {
@Override
public void run() {
x.vibrate(5000);
}
});
return true;
}
I didn't test the code but it should be fine.