28.3 Creating the GestureDetectorCompat Instance
With the activity class now updated to implement the listener interfaces, the next step is to create an instance of the GestureDetectorCompat class. Since this only needs to be performed once at the point that the activity is created, the best place for this code is in the onCreate() method. Since we also want to detect double taps, the code also needs to call the setOnDoubleTapListener() method of the GestureDetectorCompat instance:
package com.ebookfrenzy.commongestures;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.GestureDetector;
import android.widget.TextView;
import android.view.MotionEvent;
import androidx.core.view.GestureDetectorCompat;
public class MainActivity extends AppCompatActivity
implements GestureDetector.OnGestureListener,
...