Code example for MotionEvent

Methods: getActionMaskedgetXgetY

0
     * pointers and rotates the image accordingly.  As the user 
     * rotates their fingers, the image will follow. 
     */ 
    private boolean doRotationEvent(MotionEvent event) {
        //Calculate the angle between the two fingers 
        float deltaX = event.getX(0) - event.getX(1);
        float deltaY = event.getY(0) - event.getY(1);
        double radians = Math.atan(deltaY / deltaX);
        //Convert to degrees 
        int degrees = (int)(radians * 180 / Math.PI);
 
        /* 
         * Must use getActionMasked() for switching to pick up pointer events. 
         * These events have the pointer index encoded in them so the return 
         * from getAction() won't match the exact action constant. 
         */ 
        switch (event.getActionMasked()) {
            case MotionEvent.ACTION_DOWN:
            case MotionEvent.ACTION_POINTER_DOWN:
            case MotionEvent.ACTION_POINTER_UP:
                //Mark the initial angle 
                mLastAngle = degrees;