How to Add Deep Links in Jetpack Compose?
Step-by-step and easy-to-follow guide to implement deep links in your Android app using Navigation Compose library
--
This is part of the Jetpack Compose navigation series:
- Part 1 — Simple Jetpack Compose Navigation Example
- Part 2 — Compose Destinations — Navigation Library
- Part 3 — How to Add Bottom Navigation in Jetpack Compose?
- Part 4 — How to Add Navigation Drawer in Jetpack Compose?
- Part 5 — How to Add Deep Links in Jetpack Compose?
A deep link is a hyperlink that takes you directly to a certain screen on your app.
For example, clicking on my blog’s URL, the Android OS shows a list of apps that can be used to open the URL as you can see below.
Note: The UI above may look a bit different on different Android OS
Since my blog’s app supports deep links, it shows up as one of the apps, the first one from the left. If I open it with my blog’s app, it takes me to specify screen content within my app. That’s the called deep link.
To demonstrate how to implement the deep link, I use this simple Jetpack Compose navigation as an example. Let’s add the deep link.
Overview
The example app has 4 screens:
- Login Screen
- Home Screen
- Profile Screen
- Search Screen
I’m going to add the deep link for each screen in this example app.
1. Add hostname in the activity’s intent filter
In AndroidManifest.xml, add the <data>, <category> and <action> tags in the activity’s intent filter as shown below.
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
...
<activity
...
<intent-filter>
<data android:host="vinchamp77.github.io"…