Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

onTouch event sometimes not firing ACTION_POINTER_DOWN

Tags:

android

I'm trying to implement pinch-zoom in an app I'm making and am having issues with the onTouch event. It appears that the pointer up & down actions do not fire immediately, like you won't get a pointer up or down until an action move occurs. So what happens if both fingers hit the screen nearly simultaneously is that the 2nd finger (should be pointer(1)) gets a move action before pointer down is called, making the code think it's a DRAG not a pinch zoom. Anyone else seen this? Anyway around it? Thanks.

like image 531
JStew Avatar asked Jul 09 '10 19:07

JStew


2 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
like image 107
tayler Avatar answered Sep 28 '22 08:09

tayler


faced the same issue turned out that ACTION_POINTER_2_DOWN was being fired in my app when i touched the second finger and after that ACTION_MOVE was fired the getAction() method gives the event number which needs to be checked against this list

like image 20
Omkar Avatar answered Sep 28 '22 08:09

Omkar