What is Intent in Android?

Users will see a leap from one application to another as part of the whole process, such as searching for a location in the browser and seeing a direct jump into Google Maps, or receiving payment links in the Messages Application (SMS) and connecting to PayPal or GPay. This act of moving users from one application to another is accomplished by passing the intent to the system.

There are many way to used intent in Mobile application

  • Sending the User to Another App.
  • Allowing Other Apps to Start Your Activity.
  • Getting a Result from an Activity


Type of android intents 

There are two type of intent.

  • Implicit
  • Explicit
1. Implicit intents gives details about the components that the system that is going to be called  upon has available.

For example :

  Open web URL of mobile application hence write code below 

 Intent intent=new Intent(Intent.ACTION_VIEW);
 intent.setData(Uri.parse("https://www.candidroot.com/"));
 startActivity(intent);

 Output 

 

2.Explicit Intent provides the external class tot be invoked

For example :

  Open other activity from source activity of mobile application hence write code below 

 Intent intent=new Intent(this,MainActivityone.class);
startActivity(intent);

Output


  

Happy coding!

365Bloggy June 17, 2024
Share this post
Tags
SUBSCRIBE THIS FORM


Archive