What is the difference between the two approaches below?
int action1 = event.getAction() & MotionEvent.ACTION_MASK;
int action2 = event.getAction();
ACTION_MASK is used to separate the actual action and the pointer identifier (e.g. first finger touched, second finger touched, etc.) The first 8 bits of the value returned in getAction() is the actual action part, and so when you bitwise-AND it with the action mask (= 11111111 = 255 = 0xff), you are left with only the action and none of the pointer information.
Keep in mind here that
& is used as an arithmetic operator (bitwise) and not a logical operator (single
& is a perfectly valid logical operator in Java, as is