Skip to main content

Direct deep linking

If a user already has your app on their device, it will open when they interact with a tracker containing a deep link. You can then parse the deep link information for further use. To do this, you need to choose a desired unique scheme name.

You can set up a specific activity to launch when a user interacts with a deep link. To do this:

  1. Assign the unique scheme name to the activity in your AndroidManifest.xml file.
  2. Add the intent-filter section to the activity definition.
  3. Assign an android:scheme property value with your preferred scheme name.

For example, you could set up an activity called MainActivity to open like this:

<activity
android:name=".MainActivity"
android:configChanges="orientation|keyboardHidden"
android:label="@string/app_name"
android:screenOrientation="portrait">

<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="adtraceExample" />
</intent-filter>
</activity>

To open your app when a user clicks on a tracker URL, add its scheme name to the Adtrace tracker as a deep_link parameter. A tracker URL without any extra information might look like this: https://app.adtrace.io/abc123?deep_link=adtraceExample%3A%2F%2F

Important

The deep_link parameter must be URL encoded

If you follow the above example, your app will open when a user interacts with a tracker URL. Once it opens, it will launch the MainActivity activity. You will receive information about the deep_link parameter content inside the MainActivity class. The SDK will decode the parameter's content.

You can set the delivery location of the deep_link parameter content. To do this, set the android:launchMode property on your activity. You can find this in your AndroidManifest.xml file. See Android's official documentation. for more information about the android:launchMode property.

The SDK will deliver deep link information within the Intent object of your activity. It uses either the activity's onCreate or onNewIntent methods to do this. Once you have launched your app and triggered one of these methods, you can access the deep link content. You can then use this information in other places in your app.

You can extract deep link content from either of these methods like this:

Using the onCreate method:

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

Intent intent = getIntent();
Uri data = intent.getData();
// data.toString() -> This is your deep_link parameter value.
}

Using the onNewIntent method:

@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);

Uri data = intent.getData();
// data.toString() -> This is your deep_link parameter value.
}