This article discusses what deep linking is, why we use deep linking, how to enable and test deep linking in your android app.
What is deep linking ?
Deep linking provides a way to link to specific content on either a website or an application. It allows a corresponding Android app to open instead of a web browser. It can also act on any information that is contained in a particular URL or linked text. This is where deep linking starts to get really useful.
Why we use deep linking ?
Deep linking is important because it drives user engagement. Deep links can direct users to specific views within your app or other apps. It breaks the back button. For example, As you browse, you click a link to a URL at Facebook.com. By the power of deep link, this opens in the Facebook app. Without deep linking, you have two options.First , you may need to authenticate with Facebook if you’re not already signed in. The second option is exiting your app/browser and opening the facebook app where you will have to search for the same content again.
You can use this for your referral campaigns, content sharing, and in-app referrals to the services, users, and campaigns that helped users find and use your app.
How to enable deep linking ?
To enable deep linking into your application you need to use the below snippet:
- Add intent filters within the <activity> tag in Android Manifest :
intent – filter contains the below elements and attribute values
- autoVerify : The system treats your app as the default handler for the specified URI pattern. If it successfully verifies all app link patterns declared in your manifest.
- <action> : Sets the intent action to view the activity.
- <category> : Browsable : Allows the link to be opened from a web browser. Default : Allows the deep link to be used without specifying the app name.
- <data> : represents a URI format that relates to the activity.
- scheme : This is the minimal essential attribute for specifying a URI. A scheme is specified without the trailing colon (for example, http ). Scheme matching in the Android framework is case-sensitive.
- host : The host part of a URI authority.
- port : The port part of a URI authority.
- path : It must begin with a “/“. It specifies a complete path that is matched against the complete path in an Intent object.
- pathPrefix : the partial path that is matched against only the initial part of the path.
- pathPattern : It specifies a complete path that is matched against the complete path.
- mimeType : A MIME media type, such as image/jpeg or audio/mpeg4-generic.
- Read data from incoming intents :
Once the system starts your activity through an intent filter, you can use data provided by the Intent to determine what you need to render. Call the getData() and getAction() methods to retrieve the data and action associated with the incoming Intent.
How to test your deep links ?
After enabling this deep linking, you need to test whether your code works properly or not. For testing your deep links you need to run the adb command against a device or an emulator.
The general syntax for testing an intent filter URI with adb is:
For example, the command below tries to view a target app activity that is associated with the specified URI.
Now that you know how to create and use deep links.
Happy deep linking 🙂
If this post helped you, please help others by sharing this post, keep watching this space get more updates on Android Stuff!
Latest posts by Jaison Fernando (see all)
- Phone number auth using Firebase Authentication SDK - March 20, 2020
- Password-less email auth using Firebase Authentication SDK - March 9, 2020
- How to use SharedPreferences API in Android? - February 10, 2020