Do somthings

In this article, we learn What is a Intent. also, we learn how to use and implement it in an android project. In Android, it is quite usual for users to witness a jump from one application to another as a part of the whole process, for example, searching for a location on the browser and witnessing a direct jump into Google Maps or receiving payment links in Messages Application (SMS) and on clicking jumping to PayPal or GPay (Google Pay). This process of taking users from one application to another is achieved by passing the Intent to the system. in general, are used for navigating among various activities within the same application, but note, is not limited to one single application, i.e., they can be utilized from moving from one application to another as well. 

Intent could be Implicit, for instance, calling intended actions, and explicit as well, such as opening another activity after some operations like onClick or anything else.

  1. Sending the User to Another App or other Activity.
  2. Getting a Result from an Activity.
  3. Allowing Other Apps to Start Your Activity.

What is a Intent & How many Types

  1. Implicit and
  2. Explicit.

1. Implicit Intent

Implicit doesn’t specify the component. In such a case, these provide information on available components provided by the system that is to be invoked. For example, you may write the following code to view the webpage.

Intent intent=new Intent(Intent.ACTION_VIEW);  

intent.setData(Uri.parse(“http://www.dosomthings.com”));  

startActivity(intent);  

Output

Example:

In the below images, no component is specified, instead an action is performed i.e. a webpage is going to be opened. As you type the name of your desired webpage and click on ‘CLICK’ button. Your webpage is opened. 

2. Explicit Intent

Explicit intent specifies the component. In such a case, these provide the external class to be invoked.

Intent i = new Intent(ActivityFirst.this, ActivityTwo.class);  

startActivity(i);  

Example:

In the below example, there are two activities (FirstActivity, SecondActivity). When you click on the ‘GO TO OTHER ACTIVITY’ Button in the first activity, then you move to the second activity. When you click on the ‘GO TO HOME ACTIVITY’ button in the SecondActivity, then you move to the first activity. 

Output

Conclusion

So in this article, we learn What is Intent, and how to create and implement it in a project Basically we use these to swift users from one page to another page which means one class to another class we also send value to them.

Thanks, you give your precious time, and please connect with us for a more attractive and interesting article like a day/night time picker, the animated progress bar in a flutter, how to create a recycled bar, and lots more.

Categories: Android

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *