Bezel Gestures with Android

I think MotionEvent.getEdgeFlags() is what you're looking for. You can then compare the returned value with EDGE_LEFT , EDGE_RIGHT , etc to see which edge was touched.

if( event1.getEdgeFlags()&MotionEvent.EDGE_LEFT != 0 ){
    //code to handle swipe from left edge
}

or

if( e1.getX() < 5.0f ){
    //handle swipe from left edge
}

Relying on MotionEvent.getEdgeFlags is wrong. See this discussion for more info: https://groups.google.com/forum/?fromgroups=#!topic/android-developers/ZNjpzbkxeNM

Conceptually to detect a edge swipe you need to detect a drag/scroll event and also make sure the original "x" coordinate of the down event is within some distance from the edge.

The easiest way to do this is to use a GestureDetector to detect drag/scroll. Luckily onScroll method of SimpleOnGestureListener has everything you need.

So something like this (if you are using a GestureDetector configured with SimpleOnGestureListener):

 public boolean onScroll (MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {

        if (e1.getX() < SOME_DISTANCE_FROM_SCREEN) {
           //your code  
           return true;
        }
        return false;
 }