Blog purpose for android basic example for android app developer. any query please my contact

Wednesday 1 March 2023

what is intent in android and types of intent in android

 what is intent in android and types of intent in android

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. Intents, 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. 


What an Intent is in Android?

Android Intent is the message that is passed between components such as activities, content providers, broadcast receivers, services etc. It is generally used with startActivity() method to invoke activity, broadcast receivers etc. The dictionary meaning of intent is intention or purpose.


1.Implicit Intent

Implicit Intent doesn't specifiy the component. In such case, intent provides information of 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.javatpoint.com"));  

startActivity(intent);  



2. Explicit Intent

Explicit Intent specifies the component. In such case, intent provides the external class to be invoked.


Intent intent=new Intent(Intent.ACTION_VIEW);  

intent.setData(Uri.parse("http://www.javatpoint.com"));  

startActivity(intent);  


No comments:

Post a Comment