Tutorials Android How to Enable Deep Links for App Content in Android

How to Enable Deep Links for App Content in Android

Enable deep links for App content in Android, you need to fist add intent filters for the relevant activities in your application manifest. The intent filters allow deep linking to the content in any of your activities.

Add Intent Filters for Links

For example, a user clicks on a website link http://stacktips.com on the browser, that will resolve the link and open the content in installed activity.

    android:label="@string/my_app" >
    <intent-filter android:label="@string/my_app">
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <!-- Accepts URIs that begin with "http://stacktips.com/tutorials” -->
        <data android:scheme="http" android:host="stacktips.com" android:pathPrefix="/tutorials" />        

Once the above intent filters are added, Android will be able to route any Intent that has matching URIs to your app at runtime.

Read Data from Incoming Intents

Once Android system starts the routed activity through an intent filter. You can get the data bundle from Intent to determine what you which activity or fragment to render. Call the getData() and getAction() methods to retrieve the data and action associated with the incoming Intent. You can call these methods at any time during the lifecycle of the activity, but you should generally do so during early callbacks such as onCreate() or onStart().

The following code snippet shows how to retrieve data from an Intent

public void onCreate(Bundle savedInstanceState) {

    Intent intent = getIntent();
    String action = intent.getAction();
    Uri data = intent.getData();

Test Your Deep Links

You can use the Android Debug Bridge with the activity manager tool to test that the intent filter URIs you specified for deep linking resolve to the correct app activity. You can run the adb command against a device or an emulator.

The following command tries to view a target app activity that is associated with the specified URI.

$ adb shell am start -W -a android.intent.action.VIEW -d http://stacktips.com/tutorials/android com.example
Newest Most Voted
Inline Feedbacks
View all comments
lokesh goyal
lokesh goyal
6 years ago

Sir thanx for that..
Can you call particular activity of a application having deep linking with other application

Stack Tips
Stack Tips
6 years ago
Reply to  lokesh goyal

Sure you can. It will open the activity specified in android:name="com.example.MainActivity",

lokesh goyal
lokesh goyal
5 years ago
Reply to  Stack Tips

sir i tried it but it doesn’t work.
I have 2 application and using deep linking i have to open another app from first app on button click.
Please help

lokesh goyal
lokesh goyal
5 years ago
Reply to  Stack Tips

and here my 2nd application is works correctly that i can use it as deep link.
But from my 1st application when i click on the button then it doesn’t open it.
So what do i do for that

Mark Jatana
Mark Jatana
6 years ago

Saved tons of my time. Bookmarked it

6 years ago
Reply to  Mark Jatana

Thanks Mark

Previous Post

How to Programmatically Take a Screenshot in Android?

Next Post
Google Fonts Website- Material Design

Google Fonts Website Gets a Fresh New Material Design Look

Related Posts
By clicking “Allow All”, you agree to the storing of cookies on your device to enhance site navigation, analyze site usage, and assist in our marketing efforts. Cookie Notice
Allow All
Would love your thoughts, please comment.x