I have this snippet of code to detect a scroll gesture using GestureDetector. It works, except it detects the scroll activity 3 times instead of once.
How can I make it detect only once? It logs the scrolls activity (log.i line) 3 times, and plays the sound (mp.start) 3 times instead of once too.... Also causes my application to force close.
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { //get x and Y co-ordinates and log it as info. float x1 = e1.getX(); float y1 = e1.getY(); float x2 = e2.getX(); float y2 = e2.getY(); Log.i("Scroll_Gesture", "Scrolled from: (" + x1 + "," + y1 + " to " + x2 +"," + y2 + ")"); mp = MediaPlayer.create(this, R.raw.scroll_success); mp.start(); //start success page Intent intent = new Intent(this, ScrollSuccess.class); startActivity(intent); return false; }