title: detect swings to left and right in Android (onFling and OnGestureListener)
body: <p>im trying to detect when a user make a left or right swing in the activity.
  Currently I'm using a OnGestureListener and the method <a href="http://developer.android.com/reference/android/view/GestureDetector.OnGestureListener.html#onFling%28android.view.MotionEvent,%20android.view.MotionEvent,%20float,%20float%29" rel="nofollow">onFling()</a> and my problem is that I don't achieve a nice way of detecting it. </p>
  
  <p>I'd like a behaviour similar to the others applications and the "native" Android swing detection but with the code (appended below) I have a lot of wrong swing detections. If someone have already solved that I'd like a tip =)</p>
  
  <p>Thats the code I'm using </p>
  
  <pre><code>@Override
  public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,float velocityY) {
      //Get Position
      float ev1X = e1.getX();
      float ev2X = e2.getX();
  
      //Get distance of X (e1) to X (e2)
      final float xdistance = Math.abs(ev1X - ev2X);
      //Get velocity of cursor
      final float xvelocity = Math.abs(velocityX);
  
      if( (xvelocity &gt; SWIPE_MIN_VELOCITY) &amp;&amp; (xdistance &gt; SWIPE_MIN_DISTANCE) )
      {
          if(ev1X &gt; ev2X)//Switch Left
          {
              if (Manager.debug) Log.d(Manager.appname,"SWING_LEFT_EVENT");
              moveToRight();
          }
          else//Switch Right
          {
              if (Manager.debug) Log.d(Manager.appname,"SWING_RIGHT_EVENT");
              moveToLeft();
          }
      }
  
      return false;
  }
  </code></pre>