问题
I am creating an Intent in android SDK but i don't know when to use the "this" value as argument or something else.. Can someone explain what "this" is used for? I know it means something like the object it's currently in but i don't know what the value is used for.
tnx.
回答1:
this is used to refer current activity in case of Intent
回答2:
Intent
probably takes an interface as the first parameter and your object this
has an implementation of that interface.
回答3:
you're making an explicit intent which takes two parameters: The context implementing the class and the activity (class) to be opened by the intent for example:
Intent i = new Intent(this, AnotherActivity.class);
the this
is specifying the context implementing the class.
take a look at the documentation for intents : http://developer.android.com/reference/android/content/Intent.html#Intent(android.content.Context, java.lang.Class)
It will also be able to show you the difference between an implicit and explicit intent
来源:https://stackoverflow.com/questions/18785957/android-what-does-this-in-intentthis-mean