The onTouch event sometimes fails ACTION_POINTER_DOWN

I am trying to implement scaling in the application I am creating and am having problems with the onTouch event. It appears that the up and down pointer actions do not fire immediately, since you will not get an up or down pointer until an action occurs. So, what happens if both fingers hit the screen almost simultaneously is that the 2nd finger (must be a pointer (1)) receives the action of moving before calling the pointer down, forcing the code to consider its DRAG not the largest zoom. Has anyone else seen this? Anyway around? Thanks.

+6
android
source share
6 answers

be sure to include MotionEvent.ACTION_MASK in your switch. For example:

switch(event.getAction() & MotionEvent.ACTION_MASK){ case MotionEvent.ACTION_DOWN: some code break; case MotionEvent.ACTION_POINTER_DOWN: ETC 
+29
source share

faced with the same problem it turned out that ACTION_POINTER_2_DOWN was launched in my application when I touched my second finger and after that ACTION_MOVE was fired the getAction () method gives the event number that needs to be checked in this list

+1
source share

I had the same problem in my project. If I touch the screen and my fingers are too close, the system does not implement a multi-touch event. I think this is because when your fingers are too close, the system sees it as one finger.

Perhaps you can test this assumption using the getSize () method to estimate the area of ​​the screen when you touch the screen with one finger and when you touch the screen with two fingers close to them.

0
source share

It turned out that this is a problem with a custom ROM, which I highlighted on my Evo. Thanks again to Hare for their advice, as it turned out to be another mistake I had.

0
source share

I solved the same problem:

 switch(event.getActionMasked()) { case MotionEvent.ACTION_POINTER_DOWN: //your code break; } 
0
source share

I noticed that this (MotionEvent.ACTION_POINTER_DOWN) event is triggered if the onTouch (event) method returned as true , as follows:

 @Override public boolean onTouchEvent(MotionEvent event) { switch(motionEvent.getAction() & MotionEvent.ACTION_MASK) { case MotionEvent.ACTION_POINTER_DOWN: //your code break ; } return true; } 

Note: MotionEvent.ACTION_DOWN is only listened if the onTouch () method returned a boolean as return super.onTouchEvent (event); so make sure true to avoid this situation.

0
source share

All Articles