The Intent class had 6 constructors
Intent()
Create an empty intent.
Intent(Intent o)
Copy constructor.
Intent(String action)
Create an intent with a given action.
Intent(String action, Uri uri)
Create an intent with a given action and for a given data url.
Intent(Context packageContext, Class cls)
Create an intent for a specific component.
Intent(String action, Uri uri, Context packageContext, Class cls)
Create an intent for a specific component with a specified action and data.
I'm almost new in android programming and mostly using the fifth one when i need to start another Activity
or Fragment
:
Intent(Context packageContext, Class<?> cls)
When i want to start an Activity
from a Fragment
i do this:
Intent i = new Intent(getActivity(), DestinationActivity.class);
as far as i know, getActivity()
will return an Activity
But the constructor expect a Context
, how is this possible???
is it possible because of that the Activity
that had returned by getActivity()
implicitly invoke getApplicationContext()
???