添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
风度翩翩的柿子  ·  Scope functions | ...·  1 周前    · 
想出国的皮蛋  ·  Starset - Monster ...·  2 周前    · 
不开心的开心果  ·  IoTDB Website·  6 月前    · 
淡定的打火机  ·  BaseFont (iText ...·  6 月前    · 

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.

Intents 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. Below are some applications of Intents:

  • Sending the User to Another App
  • Getting a Result from an Activity
  • Allowing Other Apps to Start Your Activity
  • The collaborative nature of Android applications only results in a better user experience. The question here is if the intent is for an application that is not present in the device, what’s the next call?

    Some Important Method of Intent and their Description

    Context.startActivity() This is to launch a new activity or get an existing activity to be action. Context.startService() This is to start a new service or deliver instructions for an existing service. Context.sendBroadcast() This is to deliver the message to broadcast receivers.

    Deep Linking

    Deep Link is an URL that redirects the device to the API of that Missing Application and then the service is run on the system to check if a version of that application exists on the device. For time being, let’s assume that the application is not available on the device and no previous versions ever existed. This service then makes a call to the Play Store from the device and the application appears, just a matter of download.

    Not deviating from the topic, there are a few examples that already exist in Android Studio for redirecting to other applications, for example, Dialing Numbers, Sending SMSs, Opening Settings, etc. Everyday examples include redirecting to YouTube, Maps, WhatsApp, Facebook, etc.  Android community, especially the Kotlin Community is at its zenith every single impending day. Kotlin has witnessed a huge amount of sudden growth in the past few years and could be one of the vital tools in the future replacing Java & possibly Julia also.

    Types of Android Intents

    There are two types of intents in android

  • Implicit
  • Explicit
  • Implicit Intent

    Implicit Intent doesn’t specify the component. In such a case, intent provides 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.

    Syntax:

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

    For 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 the ‘CLICK’ button. Your webpage is opened.

    Explicit Intent

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

    Syntax:

    Intent i = new Intent(getApplicationContext(), ActivityTwo.class);  
    startActivity(i);  

    For Example: In the below example, there are two activities (FirstActivity, and SecondActivity). When you click on the ‘GO TO OTHER ACTIVITY’ Button in the FirstActivity, then you move to the SecondActivity. When you click on the ‘GO TO HOME ACTIVITY’ button in the SecondActivity, then you move to the first activity. This is getting done through Explicit Intent.

    Note : To know more about the types of intent with example code please refer to Implicit and Explicit Intents with Examples .

    Like Article
    We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy Got It !
    Please go through our recently updated Improvement Guidelines before submitting any improvements.
    This article is being improved by another user right now. You can suggest the changes for now and it will be under the article's discussion tab.
    You will be notified via email once the article is available for improvement. Thank you for your valuable feedback!
    Please go through our recently updated Improvement Guidelines before submitting any improvements.
    Suggest Changes
    Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.