0
public boolean onTouchEvent(MotionEvent event) {
    float x=event.getX()*2;
    float y=event.getY()*2;
    tv1.setText(String.valueOf(x));
    tv2.setText(String.valueOf(y));


    try {
        out = new PrintWriter(ClientSocket.getOutputStream(),true);
    switch(event.getAction()&MotionEvent.ACTION_MASK){
        case MotionEvent.ACTION_MOVE:
                out.println("x:"+x*2);
                out.println("y:"+y*2);
             break;

        case MotionEvent.ACTION_POINTER_DOWN:
            int tap=event.getPointerCount();
            int index=event.getActionIndex();
            Log.d("cv", String.valueOf(tap));
            if(tap==2){
                Toast.makeText(this,"Two Finger",Toast.LENGTH_SHORT).show();
                out.println("rightclick");

            }
            break;
    }
    } catch (IOException e) {
        e.printStackTrace();
    }
    return super.onTouchEvent(event);

}

This is the code which I using so far but it give only two finger tap & ACTION_MOVE event but I also want to detect one finger tap without interfering the ACTION_MOVE event. So please help me fast....

Hemant Sangle
  • 282
  • 3
  • 19
  • https://github.com/mohit008/Android-Move-Image – Iamat8 Oct 06 '15 at 08:51
  • I am using this code to control the mouse of my computer – Hemant Sangle Oct 06 '15 at 08:59
  • then why have you tagged android in it... – Iamat8 Oct 06 '15 at 09:03
  • because its an android code – Hemant Sangle Oct 06 '15 at 09:04
  • At least tell me how can get one finger tap event – Hemant Sangle Oct 06 '15 at 09:07
  • I am not getting whether it is your android application,or java desktop application ? – Iamat8 Oct 06 '15 at 09:10
  • I have return the server in java which is running on my computer. – Hemant Sangle Oct 06 '15 at 09:13
  • I am sending the android screen movement coordinates to the server and then set the mouse pointer location – Hemant Sangle Oct 06 '15 at 09:14
  • I would suggest to get your android screen pointer (from above link ) and then send only that coordinates to server..It will be easy to your mouse pointer then – Iamat8 Oct 06 '15 at 09:17
  • Actual my pointer is moving but I want the mouse left click is done on the one finger tap on android screen. So I want to know the way how can I detect the one finger tap. – Hemant Sangle Oct 06 '15 at 09:19
  • in android there is not right/left click ..at `ACTIONDOWN` in android send that gesture/text to your server...At server read that gesture/text and perform LEFT SIDE MOUSE CLICK...[this is reference for right/left click](http://www.codeprogress.com/java/showSamples.php?key=HandleMouseLeftRightClick&index=31) – Iamat8 Oct 06 '15 at 09:29
  • yes, I have done this look in the code case MotionEvent.ACTION_POINTER_DOWN: here I have detected the two finger tap and sending the right click text on the server. Then server reads this and tell the mouse to do the right click. like this I want the one finger tap so I can send the leftclick text to the server – Hemant Sangle Oct 06 '15 at 09:35
  • have you tried adding `if(tap==1)` – Iamat8 Oct 06 '15 at 09:39
  • yes but it give nothing. Actually it return only 2 – Hemant Sangle Oct 06 '15 at 09:43
  • in this [post](http://stackoverflow.com/a/7840953/2553431) you can count finger tap..try if it help – Iamat8 Oct 06 '15 at 09:49

0 Answers0