I have to implement swipe listeners, so that it can listen to the swipes whether from corner or edge of android device. I have implemented override method onTouchEvent(MotionEvent event) to get edge flags. But value of edge flag is always set to zero. My question is how to listen to swipes that are from corner or edge of device.
Thanks in advance.
@Override
public boolean onTouchEvent(MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN
&& (event.getEdgeFlags() == MotionEvent.EDGE_RIGHT) || event.getEdgeFlags() == MotionEvent.EDGE_LEFT) {
mOverlayLayout.setVisibility(View.VISIBLE);
return true;
} else if (event.getFlags() == MotionEvent.FLAG_WINDOW_IS_OBSCURED) {
mOverlayLayout.setVisibility(View.INVISIBLE);
return true;
}
return false;
}
You can create OnSwipeTouchListener.java
Usage:
});
Reference: https://stackoverflow.com/a/12938787/7199177