Long Press Android to Java

283 views Asked by At

I'm trying to program a Mouse via Wifi TCP. Client is on Android and Server on Java. I'm trying to detect a LongPress on Android and send this information to Java.

Android: I need to implement MotionEvent.ACTION_DOWN but I don´t know what to do after this code.

Java: How the class Robot receive those parameters who MotionEvent sends, and how implement the LongPress on both client and server.

2

There are 2 answers

1
Susheel On BEST ANSWER

You could use a button.setonlongclicklistener? Check out this example: http://androidbite.blogspot.com/2013/03/android-long-press-event-handle-example.html

0
Marcos Vasconcelos On
if(motionEvent.isActionDown())
    new Handler().postDelayed(new Runnable(){
     public void run(){
          onLongPressListener.fire();
     }
  }, 500);

You can send as messages delayeds and clear the messages with an ID.