The Intent class had 6 constructors
Intent()
Create an empty intent.
Inten
Take a look at the argument Context
very closely in the fifth Intent declaration. It reflects polymorphism. The Intent
takes a Context
argument so you can pass any object that is a Context
or derives from the Context
class.
Activity, AppCompatActivity, IntentService, Service all derive from the Context
class and hence can be passed as an argument to the method.
Activity extends Context so you can just cast it:
Intent i = new Intent((Context)getActivity(), DestinationActivity.class);
Activity inherits context. Thus, if you are in an activity, you only need to pass itself to use the context. It also contains a pointer to getBaseContext(). You might occasionally need to reference that, if you need the entire application context, but most likely you won't for a while.
You can find more details about the Activity class here.
This question about the intent constructor parameters is similar to yours and has a really good answer. I think you'd like to check it out.
Hope it helps.