INTENTS
INTENTS
TYPES OF INTENTS
1. Implicit Intents
For Example:
Intent intent=new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(“https://www.geeksforgeeks.org”));
startActivity(intent);
2. Explicit Intents
specifies the component. In such a case, intent provides the external class to be
invoked.
For Example:
Intent i = new Intent(getApplicationContext(), ActivityTwo.class);
startActivity(i);
HOW TO DIFFER THE TWO TYPES OF INTENT CALLING
Explicit intent can do the specific application It specifies the only action to be
action which is set by the code like changing performed and does not directly
activity, downloading the file in the background, specify Android Components.
etc.
In explicit intent, you can pass data to other Here we just mention the action in
activities by using the putExtra method and the intent and OS decides which
retrieve by using getIntent(). applications are suitable to handle
the task, action across two different
Example:
applications.
val intent = Intent(this, SecondActivity::
class.java).apply{
putExtra(“key”,”New Value”)
startActivity(intent)
Second Screen:
In explicit intent, the action target is delivered When you make an implicit call with
even the filter is not consulted. the intent. OS look at the action and
then it matches with all the filters
intent-filters of all the registered
activities of all application using
PackageManager and then populates
the result as a list, this process is
called as intent Resolution.
PRACTICE ACTIVITY
4. On the Project Tab’s res folder -> layout, right click and select New then click on
Layout Resource File
5. Type the name of the Layout Resource File as “page_one” and click OK button.
6. On your Project tab’s app folder -> manifests, open the AndroidManifest.xml file
13. In the body of your PageOne class add the following code below.
14. Run the program to test the three button.
15. Result