Deep Links

A deep link opens the app on a specific screen from a URI: a notification, another app, a web page. It takes two declarations. The destination names its URI pattern (the navDeepLink<BookDetail>(basePath = "booknest://book") of Type-Safe Routes, which expands to booknest://book/{id}), and the manifest lets the activity receive such URIs:

AndroidManifest.xml: the activity accepts booknest://book linksXML
            <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="booknest" android:host="book" />
            </intent-filter>

NavHost checks the activity's intent when it creates its graph. Test from the command line with the app stopped:

Opening book 5 by deep link, then pressing BackShell
adb -s emulator-5556 shell am start -a android.intent.action.VIEW -d "booknest://book/5"
adb -s emulator-5556 shell input keyevent KEYCODE_BACK
adb -s emulator-5556 logcat -d -v tag -s BookNestNav:D
Output
Starting: Intent { act=android.intent.action.VIEW dat=booknest://book/... }
--------- beginning of main
D/BookNestNav: now at com.example.booknest.ui.nav.Catalog id=5
D/BookNestNav: now at com.example.booknest.ui.nav.BookDetail/{id} id=5
D/BookNestNav: now at com.example.booknest.ui.nav.Catalog id=5

The app opened on The Clockmaker's Paradox, and Back went to the catalog, not out of the app: Navigation built a synthetic back stack from the start destinations of the graphs above the target, handing them the link's arguments too (hence id=5 on the catalog). Any app may claim a custom scheme; for https:// links use verified Android App Links (android:autoVerify="true" plus /.well-known/assetlinks.json on your domain with your signing key's SHA-256 fingerprint; not run here). If the activity is already running, deliver new links in onNewIntent with navController.handleDeepLink(intent).