How To Add Deep Linking Support To Your Android App?

Add deep linking support to your app
App deep links helps users access content inside your app while browsing the web on their smartphone. They are like hyperlinks, but instead of a webpage, they open an app page with the content that the user is looking for. Google has incorporated the app indexing feature into its search results, which makes it possible for app developers to make their app's content available to the search engine. However, for app indexing to work properly, the first step is to enable support for deep links inside your Android apps.

Adding Deep Link support to Android apps

In order for Google to be able to index your Android app and make it contents available in search results, you have to primarily define an intent filter inside your app manifest file. Every app has a manifest file which defines all the activities and processed of an app, and how objects communicate.

An Intent is a messaging object you can use to request an action from another app component. Intents primarily facilitate communication between components. In this post, I'll show you how to create an intent to enable deep linking inside your app.

If you're new to Android apps, or want to get started: How To Create Your First "Hello World" Android App?

Defining an intent filter

Intent filters are added inside your app manifest file. To define an intent filter;

Step 1: Intent filter element - Add an <intent-filter> element for each activity that should be launchable from Google Search results.

Step 2: Action tag - Add an <action> tag that specifies the ACTION_VIEW intent action inside the intent filter to .

Step 3: Data tag - Add a <data> tag for each data URI format the activity accepts. This is the primary mechanism to declare the format for your deep links.

Step 4: Category - Add a <category> for both BROWSABLE and DEFAULT intent categories.

Note: BROWSABLE is required in order for the intent to be executable from a web browser. Without it, deep linking won't work. DEFAULT is not required if your only interest is providing deep links to your app from Google Search results. However, it is if you want your Android app to respond when users click links from any other webpage that points to your website.

Putting it together

The following example shows an activity that allows users to enter the app using an intent to view information about recipes. The intent filter declares that the activity responds to VIEW action intents containing URIs that begin with http://somecookbook.com/recipe:
<activity android:name="com.somecookbook.android.RecipesActivity"
   android:label="@string/title_recipes" >
   <intent-filter android:label="@string/filter_title_viewrecipes">
      <action android:name="android.intent.action.VIEW" />
      <data android:scheme="http"
     android:host="somecookbook.com"
 android:pathPrefix="/recipes" />
      <category android:name="android.intent.category.DEFAULT" />
      <category android:name="android.intent.category.BROWSABLE" />
   </intent-filter>
</activity>
In this example, your app would respond to deep links such as http://somecookbook.com/recipe?123 or http://somecookbook.com/recipe/123 etc.

These were the basics of enabling deep link support for your app. We'll dig deeper in future posts, discussing how to restrict access to your app's content, and much more! In the meantime, if you have any questions, please feel free to ask in the comments section below! Stay tuned ;)

If you don't want to get yourself into Serious Technical Trouble while editing your Blog Template then just sit back and relax and let us do the Job for you at a fairly reasonable cost. Submit your order details by Clicking Here »

Post a Comment

PLEASE NOTE:
We have Zero Tolerance to Spam. Chessy Comments and Comments with 'Links' will be deleted immediately upon our review.