0

the problem is that i only recieve the data that sent from the client to the server after hitting the imagebutton and the event was action down. i found out that the checking on event_up never send the data - the if never happanes. the part of the code looks like that :

@Override
public boolean onTouch(View v, MotionEvent event) {

    switch (v.getId()) {
        case R.id.Abtn:
            onControl("BA", event);
            break;
        case R.id.Bbtn:
            onControl("BB", event);
            break;
        case R.id.Xbtn:
            onControl("BX", event);
            break;
        case R.id.Ybtn:
            onControl("BY", event);
            break;
        case R.id.Rbtn:
            onControl("BR", event);
            break;
        case R.id.Lbtn:
            onControl("BL", event);
            break;
        case R.id.UpBtn:
            onControl("BU", event);
            break;
        case R.id.Dbtn:
            onControl("BD", event);
            break;
        case R.id.RTbtn:
            onControl("RT", event);
            break;
        case R.id.LTbtn:
            onControl("LT", event);
            break;
        case R.id.Start_btn:
            onControl("ST", event);
            break;
        case R.id.Back_btn:
            onControl("CK", event);
            break;
        case R.id.RB_btn:
            onControl("RB", event);
            break;
        case R.id.LB_btn:
            onControl("LB", event);
            break;


    }
    return true;
}

on control:

private void onControl(String st, MotionEvent event){
    if(event.getAction() == MotionEvent.ACTION_DOWN){
        new SendMessage().execute("S"+ st);
    }
    else if(event.getAction() == MotionEvent.ACTION_UP){
        new SendMessage().execute("P "+ st);
    }
}

i checked in the internet and every answer says i need to return true, but im doing it in OnTouch. i cant figure out the solution myself. important to say that the app itself is only landscape so there is no need for check for action_cancled...

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Ido
  • 55
  • 7
  • i tried adding action _cancle just for and still not working.. – Ido Apr 02 '18 at 15:45
  • im stiil having that problem and i dont have much time.. do u think this problem may be caused from an "error" i have that says: "Custom view 'ImageButton' has setOnTouchLIsterner called on it but does not override performClick" ??? im not sure what to think about this problem anymore im serching everywhere. – Ido Apr 03 '18 at 11:37

0 Answers0