I have seen a convention in android programming, that when forexample calling another activity from some activity:
Intent i=new Intent(Caller.this,Called.class);
startActivity(i);
My question is why we write Caller.this instead of just writing this?
You only need
Caller.thisif you are inside an inner class.For example:
Here,
thisis not an instance ofCaller, but rather an instance of an anonymous inner class inheriting fromView.OnClickListener. To get to the “outer”this, you prefix it with the outer class name (i.e.,Caller.this).