5 minutes

How to Enable Deep Links for App Content in Android

By Editorial @stacktips, On Sep 17, 2023 Android 2.38K Views

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 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 "” -->
        <data android:scheme="http" android:host="" android:pathPrefix="/articles" />        

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 com.example
stacktips avtar


StackTips provides programming tutorials, how-to guides and code snippets on different programming languages.