MotionEvent.ACTION_CANCEL is blocking subsequent ACTION_UP on my button

I have a button on one of my fragments that is inside a relative layout. It's a pretty big button, and when I have a fat finger, I get the ACTION_CANCEL motion event and not ACTION_DOWN (it works great with my fingertips). This prevents it from registering a subsequent ACTION_UP (I am assuming the parent view takes). I have tried using the requestDisallowInterceptTouchEvent () method on the parent, to no avail.

Here is my onTouch implementation:

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

    //debugging
    Log.v("TOUCH EVENT", event.toString());


    int action = event.getAction(); 





    if (action == MotionEvent.ACTION_DOWN) {
        mButton.getParent().requestDisallowInterceptTouchEvent(true);
        //Do stuff...

        return true;

    } else if (action == MotionEvent.ACTION_UP) {

        //Do other stuff...

        return true;

    } else if (action == MotionEvent.ACTION_CANCEL){

        return false;
        //Toast.makeText(context, "Your thumb is too fat.", Toast.LENGTH_SHORT).show();
    }


    return false;
}

      

Note that the button also uses custom background resources. I run AsyncTask when the button is clicked and the background changes based on the progress of this task. I'm not sure if this has anything to do with the problem or not.

EDIT: I have walked the entire View hierarchy up to ViewRootImpl and still have no luck in calling requestDisallowInterceptTouchEvent (). The weird thing is that this shows in the log when my button sticks:

08-26 11: 06: 15.287: D / ViewRootImpl (5428): [ViewRootImpl] cancel action - 1, s: 31 s (atmel): - 1.0 eccen: 1.3333334

Thus, it is obvious that the action is canceled before it even gets inside the ViewRootImpl or immediately after it. How is this possible?

Update: Still no progress on this ... anyone?

Update 2: I think it might be a device specific issue. I am using Galaxy S4

+3


source to share


1 answer


This seems to be a problem with the device with Galaxy S4, I was unable to reproduce it on other devices. I ended up just canceling the task if found MotionEvent.ACTION_CANCEL

.



+3


source







All Articles