Code example for GestureDetectorCompat

            OnTouchListener {
        private GestureDetectorCompat detector;
        public TagDetector(Context context) {
            detector = new GestureDetectorCompat(context, this);
        public boolean onSingleTapUp(MotionEvent e) {
            float locationX = getXPercent(e.getX()); // mRootView.getWidth();
            float locationY = getYPercent(e.getY());
            createTag(null, locationX, locationY);
            Log.d(TAG, "Tap on screen");
            return super.onSingleTapConfirmed(e);
        public boolean onTouch(View v, MotionEvent event) {
Connect your IDE to all the code out there  Get Codota for Java