title: Check which direction was flinged in a Motion event android
body: <p>So i want to detect which direction the user moved his finger when touching the screen
  Right now its working for 3 directions but the "up" movement does not get called.</p>
  
  <p>This is my code:</p>
  
  <pre><code>@Override
  public boolean onTouchEvent(MotionEvent event) {
  
  switch (event.getAction()) {
  case MotionEvent.ACTION_DOWN: {
      // store the X value when the user's finger was pressed down
      downXValue = event.getX();
      downYValue = event.getY();
      break;
  }
  
  case MotionEvent.ACTION_UP: {
      // Get the X value when the user released his/her finger
      float currentX = event.getX();
      float currentY = event.getY();
          //check if horizontal or vertical movement was bigger
      if (Math.abs(downXValue - currentX) &gt; Math.abs(downYValue)
          - currentY) {
      Log.e("motionevent", "x");
      // going backwards: pushing stuff to the right
      if (downXValue &lt; currentX) {
          Log.e("motionevent", "right");
  
      }
  
      // going forwards: pushing stuff to the left
      if (downXValue &gt; currentX) {
          Log.e("motionevent", "left");
  
      }
  
      } else {
      Log.e("motionevent", "y");
      if (downYValue &lt; currentY) {
          Log.e("motionevent", "up");
  
      }
      if (downYValue &gt; currentY) {
          Log.e("motionevent", "down");
  
      }
      }
      break;
  }
  }
  
      return true;
  }
  </code></pre>
  
  <p>Is there a Problem with checking for horizontal or vertical movement? because whenever i do an up movement, right or left gets called. down works fine.</p>