The GestureDetector does not work (example from android developer)
You are creating a GestureDetector but you are never "hooking it up" to your View. Try changing your onCreate like this:
super.onCreate(savedInstanceState);
View v = new RelativeLayout(this);
v.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
setContentView(v);
mDetector = new GestureDetectorCompat(this, this);
mDetector.setOnDoubleTapListener(this);
v.setOnTouchListener(new OnTouchListener(){
public boolean onTouch(View v, MotionEvent me){
return mDetector.onTouchEvent(me);
}
});
Little late, but my solution of this problem is:
@Override
public boolean onTouchEvent(MotionEvent event) {
this.mDetector.onTouchEvent(event);
return super.onTouchEvent(event);
}
The return of the Detector gone lost. Change to:
@Override
public boolean onTouchEvent(MotionEvent event) {
if (this.mDetector != null) return this.mDetector.onTouchEvent(event);
return super.onTouchEvent(event);
}
But is this a good solution? Time for Android Insider. ;)
Tschau Fred