5

I am implementing GestureDetector.OnGestureListener in Activity, whose overridden onTouchEvent is :

public boolean onTouchEvent(MotionEvent event) {
       //gestureDetector is new GestureDetector(this,this) in Activity's onCreate()
       this.gestureDetector.onTouchEvent(event);
       return super.onTouchEvent(event);
    }

Using getEdgeFlags from MotionEvent Class for edge detection as follows:

 @Override
public boolean onDown(MotionEvent e) {
    final int edgeInfo = e.getEdgeFlags();
    return ((edgeInfo == MotionEvent.EDGE_LEFT) || (edgeInfo == MotionEvent.EDGE_RIGHT)) ||
            (edgeInfo == MotionEvent.EDGE_BOTTOM);
}

But onDown always returns false. I have also tried changing

final int edgeInfo = e.getEdgeFlags(); to
final int edgeInfo = e.getAction() & e.getEdgeFlags();

and also to final int edgeInfo = e.getActionMasked() & e.getEdgeFlags(); in case.

But to avail no benefit.

I have seen this question and this one, more relevant to me but I found that only

  1. Only some older phones return non zero value
  2. I should do it myself.

Am I Using API wrong?

Is there a better alternative to getEdgeFlags()?

Even if onDown is returning false,in logcat, I can still see other methods of GestureDetector.OnGestureListener getting fired,Why?

A little snippet would help if any.

Community
  • 1
  • 1
bharat
  • 105
  • 1
  • 1
  • 8

0 Answers0