Android - why there is a different Action_mask value for different devices

I created an application that works fine on devices under version 4.0, or we can say that ics, but above ics it does not work as it should. In my application, I tried to make multi-touch on two buttons at the same time, and it worked perfectly under version 4.0. The value of action_mask was 6th 5 when touched and touched .. whereas in versions above 4.0 its 1, 2, 0. why is this?

enter code here @override public boolean ontouch(Event ev , MotionEvent event) { int actionResolved = event.getAction() & MotionEvent.ACTION_MASK; int action = paramMotionEvent.getAction() & MotionEvent.ACTION_POINTER_INDEX_MASK; // int actionShift = paramMotionEvent.getAction() & MotionEvent.ACTION_POINTER_INDEX_SHIFT; Log.i("fil", "action resolved" +actionResolved); if(i==MotionEvent.ACTION_DOWN) { Log.i("fil", "action down"); Log.i("fil", "action down value" +MotionEvent.ACTION_DOWN); } if(actionResolved == 5); { Log.i("fil", "action resolved" +actionResolved); scannerview1.startAnimation(anim1); scannerView2.startAnimation(anim1); } if(actionResolved ==6) { scannerView2.clearAnimation(); scannerview1.clearAnimation(); } return true; } 
+4
source share
2 answers

I solved the problem above using pointer identifiers in action down. but this code is not used below version 4.0

here is my code

 @override public boolean ontouch(Event ev , MotionEvent event) { switch (event.getAction() & MotionEvent.ACTION_MASK) { case MotionEvent.ACTION_DOWN: Log.i("D3", "pid" +event.getPointerId(0)); //Log.i("D3", "pid" +event.getPointerId(1)); if(event.getPointerId(0)==0){ } if(event.getPointerId(0)==1) { scannerview1.startAnimation(anim1); scannerView2.startAnimation(anim1); } break; case MotionEvent.ACTION_UP: scannerView2.clearAnimation(); scannerview1.clearAnimation(); break; } return true; } 
+1
source

Instead

 if(actionResolved == 5); 

Using

 if(actionResolved == ACTION_POINTER_1_DOWN); 

Constant values ​​can and do vary between versions of the API.

Also note that MotionEvent.ACTION_MASK deprecated. Instead, you should use "MotionEvent.ACTION_POINTER_INDEX_MASK".

http://developer.android.com/reference/android/view/MotionEvent.html#ACTION_POINTER_INDEX_MASK

0
source

All Articles