37
loading...
This website collects cookies to deliver better user experience
Intent intent = new Intent(getActivity(), MainActivity.class);
startActivity(intent);
An intent is an abstract description of an operation to be performed
. This simply means that anytime you hear or read the word intent
you should automatically think to yourself, ok, some sort of work is about to be done. An intent can also be thought of as the glue between activities, as it is often used to share information.new Intent(getActivity(), MainActivity.class)
MainActivity.class
. While the component name is optional, it is a very important piece of information to provide, especially when defining an explicit intent. No component name, no explicit intent. Without a component name the intent becomes implicit
and the Android system must use other information(action, data and category) to determine what component is the appropriate one to call.component name
because in our example that is only what we use. If you wish to learn more about the intent information then you should read the documentation HERE
Intent intent = new Intent(getActivity(), MainActivity.class);
startActivity(intent);
component name
and making this intent an explicit intent. Lastly we call startActivity(intent)
, which will use the information stored inside of the intent object to open the correct activity. With that being said we now have a light understanding on what an intent is and what it does.