I'm trying to build an app that uses gestures to control volume and brightness. I have seen few videos that tell how to use gestures but not how to control volume and brightness. My main goal is when i swip on the left side of screen it control the volume, if i swip on the right side of the screen it control the brighness. The only code that i found to use gesture is this:
class MyGestureListener extends GestureDetector.SimpleOnGestureListener {
@Override
public boolean onDown(MotionEvent event) {
Log.d("TAG","onDown: ");
// don't return false here or else none of the other
// gestures will work
return true;
}
@Override
public boolean onSingleTapConfirmed(MotionEvent e) {
Log.i("TAG", "onSingleTapConfirmed: ");
return true;
}
@Override
public void onLongPress(MotionEvent e) {
Log.i("TAG", "onLongPress: ");
}
@Override
public boolean onDoubleTap(MotionEvent e) {
Log.i("TAG", "onDoubleTap: ");
return true;
}
@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2,
float distanceX, float distanceY) {
Log.i("TAG", "onScroll: ");
return true;
}
@Override
public boolean onFling(MotionEvent event1, MotionEvent event2,
float velocityX, float velocityY) {
Log.d("TAG", "onFling: ");
return true;
}
}
}
Any idea from where i can start?
This is my first answer in SO. I am posting some code here that is working for controlling volume. This code uses OnTouchListener for touch event, not GestureDetector.
May be this is helpful..