Cuelogic Blog Icon
Cuelogic Career Icon
Home > Blog > All > Deep Linking in Android

Deep Linking in Android

Deep Linking in Android

Deep Linking is a methodology for launching a native mobile application via a link. It consists of a unique URI (Uniform Resource Identifier) that links or matches to a specific location within a mobile app.

For example is a url that contains a key ‘cd’ with a value 23424 which is a user registration id. You can process this url and retrieve data from it.

Basically, all Android apps are composed of a set of Activities. Each of these Activities can be called by other apps if configured properly in AndroidManifest.xml file. Depending on your requirement you can launch the specific Activity once a user clicks on the deep link.

It is important to note that once a user clicks on a deep link, the Android Activity will launch on top of the current visible Activity (In case if app is open). So it is your responsibility to ensure the appropriate view hierarchy of the application. Also when the app is opened through deep link, you can retrieve the URL and process it according to your needs.

Here is a quick demo of Deep Linking implementation in Android application.

To make a clickable link in web browser we would require a html file. Create a file named index.html and put the below code in it, you can store this file on your SD card and open it using a web browser like Google Chrome.

    Registration Link : <a href =""> Register Here </a>

The index.html preview will look something like this.


Changes need to be done in AndroidManifest.xml file:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android=""

            <!-- Note: android:launchMode="singleTask" 
            The system creates the activity at the root of a new task 
            and routes the intent to it. However, if an instance of the 
            activity already exists, the system routes the intent
            to existing instance through a call to its onNewIntent() method,
            rather than creating a new one. -->

                <!-- Note: android:name="android.intent.action.VIEW"
                To make intent filter can be reached from Google Search. -->

                <action android:name="android.intent.action.VIEW" />

                <!-- Note: android:name="android.intent.category.DEFAULT"
                This is optional category, but recommended. 
                Without this category, the activity can be started 
                only with an explicit intent, using your app component name. -->

                <category android:name="android.intent.category.DEFAULT" />

                <!-- Note: android:name="android.intent.category.BROWSABLE"
                To safely invoke this Activity from a browser when a 
                user clicks on a hyperlink. -->

                <category android:name="android.intent.category.BROWSABLE" />

                <!-- Note: The <data> tag used to represent 
                a URI format that resolves to the activity. 
                You can add additional attributes to further refine 
                the type of URI that the activity accepts. 
                For example like android:host="”,
                android:scheme="https” and android:pathPrefix="/registration" -->

                    android:scheme="https" />

To process the data received from deep linking you need to write the Activity class.
Create a class and put  the code displayed below in it.


import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;

// Used to demonstrate the Deep linking functionality in Android app.

public class DeepLinkingActivity extends AppCompatActivity {

    public static final String KEY_CD = "cd";

    private Uri uriData;
    private TextView dataTextView;

    protected void onCreate(Bundle savedInstanceState) {

        dataTextView = (TextView) findViewById(;

    protected void onResume() {

        Intent intent = getIntent();

        if(intent != null) {
            uriData = intent.getData();

            if (uriData != null) {

                //To get scheme.
                String scheme = uriData.getScheme();

                //To get server name.
                String host = uriData.getHost();

                //To get parameter value from the URI.
                String parameterValue = uriData.getQueryParameter(KEY_CD);

                StringBuilder builder = new StringBuilder();
                builder.append("Data Received From URI:\n"+uriData.toString()+"\n");
                builder.append("Scheme: "+scheme+"\n");
                builder.append("Host: "+host+"\n");
                builder.append("CD key value: "+parameterValue+"\n");

                // Set the retrieved value to dataTextView.

     * To get the latest intent object.
     * @param intent
    protected void onNewIntent(Intent intent) {

Now run the Android application. Once the app runs successfully, open the index.html file in your favorite browser and click on the "Register Here" link, Android system will show you the list of apps that can open the link. This list will have your application as well, as shown in the image:


Select your application, this will launch your app and process the data received from deep link, as shown in the image: