The this
keyword, which exists in many OOP languages, is a reference to the current instance of the object in which you are contained in memory..
Your example:
this.gestureDetector = new GestureDetectorCompat(this,this);
You are basically saying:
This instance – access gestureDetector
is equal to a new instance of GestureDetectorCompat
that is constructed with 2 paramaters, in this case, both of them references to this instance of MainActivity
.
As people are saying, this is a fundamental principal and it may be more beneficial for you to start with building a strong foundation in Java before moving on to Android.