What is the difference between this
and ActivityClass.this
when you pass in to intent constructor
for example given 2 activities: ActivityOne and ActivityTwo
the following doesn't work (compile error)
@Override
public void onClick(View v) {
Intent intent = null;
Log.i(TAG, this.toString());
Log.i(TAG, ActivityOne.this.toString());
intent = new Intent(this, ActivityTwo.class);
startActivity(intent);
}
while this works
@Override
public void onClick(View v) {
Intent intent = null;
Log.i(TAG, this.toString());
Log.i(TAG, ActivityOne.this.toString());
intent = new Intent(ActivityOnethis, ActivityTwo.class);
startActivity(intent);
}
The logging info from the log is
activitylab.ActivityOne$1@41fc5818
activitylab.ActivityOne@41fa2948
although they are different, but the common answer for passing activity is usually using this
, I am not why I am running into this problem