Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android: difference between ACTION_UP and ACTION_POINTER_UP

from the android doc alone i dont really understand the difference between ACTION_UP and ACTION_POINTER_UP. http://developer.android.com/reference/android/view/MotionEvent.html#ACTION_DOWN

basically i want to capture the event when one finger is released from the screen (even if another one may still be touching it)

thanks!

like image 599
clamp Avatar asked Nov 24 '10 15:11

clamp


People also ask

What is Action_up and Action_down?

Each pointer has a unique id that is assigned when it first goes down (indicated by ACTION_DOWN or ACTION_POINTER_DOWN ). A pointer id remains valid until the pointer eventually goes up (indicated by ACTION_UP or ACTION_POINTER_UP ) or when the gesture is canceled (indicated by ACTION_CANCEL ).

Which MotionEvent constant is used to detect multi touch gestures?

You should always use the method getActionMasked() (or better yet, the compatibility version MotionEventCompat. getActionMasked() ) to retrieve the action of a MotionEvent . Unlike the older getAction() method, getActionMasked() is designed to work with multiple pointers.


1 Answers

Start here if you haven't read it already: http://android-developers.blogspot.com/2010/06/making-sense-of-multitouch.html

Android thinks about touch events in terms of gestures. A gesture in this sense includes all events from the first finger that touches the screen to the last finger that leaves the screen. A single gesture's entire event sequence is always sent to the same view that was picked during the initial ACTION_DOWN unless a parent intercepts the event stream for some reason. If a parent intercepts a child's event stream, the child will get ACTION_CANCEL.

If you're working with multitouch events, always use the value returned by getActionMasked() to determine the action. If you don't need multitouch or are working with an older platform version, you can ignore the ACTION_POINTER_* events.

  • ACTION_DOWN is for the first finger that touches the screen. This starts the gesture. The pointer data for this finger is always at index 0 in the MotionEvent.
  • ACTION_POINTER_DOWN is for extra fingers that enter the screen beyond the first. The pointer data for this finger is at the index returned by getActionIndex().
  • ACTION_POINTER_UP is sent when a finger leaves the screen but at least one finger is still touching it. The last data sample about the finger that went up is at the index returned by getActionIndex().
  • ACTION_UP is sent when the last finger leaves the screen. The last data sample about the finger that went up is at index 0. This ends the gesture.
  • ACTION_CANCEL means the entire gesture was aborted for some reason. This ends the gesture.
like image 142
adamp Avatar answered Sep 23 '22 14:09

adamp