Deep Links in Android: Getting Started

In this tutorial you’ll learn how to use intent filters to create deep links in to your Android app. By Harun Wangereka.

Leave a rating/review
Download materials
Save for later
Share
You are currently viewing page 3 of 3 of this article. Click here to view the first page.

Viewing Analytics Data

You added the necessary logic to record analytic events. Now, go to the Firebase console and open the Dynamic Links section. You’ll see something like this:

Firebase Dynamic Links Analytics Data

As you can see, you have the data on the number of:

  • Clicks
  • First opens
  • Re-opens

You can expand the link and see more insights about how your Dynamic Link is fairing.

Invoking a Deep Link Multiple Times

If your deep link activity stays in the foreground, and you invoke the deep link again, multiple instances of the activity stay in the backstack. To prevent this, add the following attribute to your activity definition in AndroidManifest.xml:

android:launchMode="singleTask"

This code ensures only one instance of the activity can exist at a single time. It also helps you avoid running into unexpected backstack issues.

In PromoActivity.kt, add the following code below showDynamicLinkOffer:

override fun onNewIntent(intent: Intent?) {
  super.onNewIntent(intent)
  intent?.let { newIntent ->
    handleIntent(newIntent)
  }
}

Here you call handleIntent() with the intent received in onNewIntent which is called when your activity is in the foreground and receives a new intent. Depending on which method you use, you can call handleFirebaseDynamicLinks() or handleIntent().

Build and run. Click the link from Firebase Dynamic Link. You’ll see:

Promo Code from Deep Link

Now when you invoke the deep link multiple times, you’ll have the correct flow without unexpected issues.

Where To Go From Here?

Download the final version of this project using the Download Materials button at the top or bottom of this tutorial.

Congratulations! You learned how to use deep links to improve your app’s user experience. You also learned how to take advantage of Firebase Dynamic Links to create deep links that work across all platforms.

To learn how to create deep links when using the Jetpack Navigation Component, check out Navigation Component for Android Part 2: Graphs and Deep Links.

I hope you enjoyed the tutorial. If you have any questions or comments, please join the forum discussion below.