Possible Duplicate:
What is Context in Android?
i read context in android current state of the application/object
Intent intent=new Intent(this,SecondaryActivity.class);
startActivity(intent);
in the place of this we can use getApplicationContext()
but in an
@Override
public void onClick(View view) {
Toast.makeText(getApplicationContext(), "Hai",Toast.LENGTH_LONG).show();
}
we can’t use this here i mean in getApplicationContext() why this also refers to the current object ,hence am confused about this and context help me to study this,an reference share me..
When you pass
thisto method, you mean thatthisreference is an instance ofContext, so if you are in Activity you can pass this instead of Context. But when you are in anonymous class:To pass
ContextinonClickmethod you can write