1

In my app, some views react to onLongClick. In others, I want to achieve the same functionality, but I want to know which part of the view was long-clicked -- so I'm simulating it with onTouchEvent. The default device behavior on the long click is vibration. I would like to do the same on a simulated long click.

I know how to get permission for the vibrator and do whatever I want with it. Is that the only way? I'm looking for a function that does a "default" vibrate, like playSoundEffect plays a handful of default system sounds. Basically, all I want to do is perform a default system reaction to a long click. It may not even be vibration on some devices...

user1334767
  • 587
  • 4
  • 17

1 Answers1

4

Basically, onLongClick just return true and it will confirmed (vibrate). When returnning false it will not vibrate.

view.setOnLongClickListener(new View.OnLongClickListener()
            {
                @Override public boolean onLongClick(View view)
                {
                    doSomething();
                    return true;
                }
            });
Eliran Kuta
  • 4,148
  • 3
  • 24
  • 28