Skip to content

deonmenezes/mobile-app-skill / skills/navigation-3

navigation-3

Verified

Learn how to install and migrate to Jetpack Navigation 3, and how to implement features and patterns such as deep links, multiple backstacks, scenes (dialogs, bottom sheets, list-detail, two-pane, supporting pane), conditional navigation (such as logged-in navigation versus anonymous), returning results from flows, integration with Hilt, ViewModel, Kotlin, and view interoperability.

FileKindSize
SKILL.mdskill md6.5 KB
references/android/guide/navigation/navigation-3/index.mdmarkdown3.5 KB
references/android/guide/navigation/navigation-3/migration-guide.mdmarkdown26.5 KB
references/android/guide/navigation/navigation-3/recipes/animations.mdmarkdown6.4 KB
references/android/guide/navigation/navigation-3/recipes/basic.mdmarkdown3.5 KB
references/android/guide/navigation/navigation-3/recipes/basicdsl.mdmarkdown3.5 KB
references/android/guide/navigation/navigation-3/recipes/basicsaveable.mdmarkdown3.5 KB
references/android/guide/navigation/navigation-3/recipes/bottomsheet.mdmarkdown7.7 KB
references/android/guide/navigation/navigation-3/recipes/common-ui.mdmarkdown8.5 KB
references/android/guide/navigation/navigation-3/recipes/conditional-transitions.mdmarkdown8.4 KB
references/android/guide/navigation/navigation-3/recipes/conditional.mdmarkdown9.4 KB
references/android/guide/navigation/navigation-3/recipes/deeplinks-custommatcher.mdmarkdown7.1 KB
references/android/guide/navigation/navigation-3/recipes/deeplinks-staticuri.mdmarkdown5.5 KB
references/android/guide/navigation/navigation-3/recipes/deeplinks-syntheticbackstack.mdmarkdown7.7 KB
references/android/guide/navigation/navigation-3/recipes/deeplinks-uriarguments.mdmarkdown15.4 KB
references/android/guide/navigation/navigation-3/recipes/dialog.mdmarkdown4.4 KB
references/android/guide/navigation/navigation-3/recipes/lifecycle-owner.mdmarkdown8.2 KB
references/android/guide/navigation/navigation-3/recipes/material-listdetail.mdmarkdown6.4 KB
references/android/guide/navigation/navigation-3/recipes/material-supportingpane.mdmarkdown6.6 KB
references/android/guide/navigation/navigation-3/recipes/modular-hilt.mdmarkdown9.6 KB
references/android/guide/navigation/navigation-3/recipes/modular-koin.mdmarkdown10.3 KB
references/android/guide/navigation/navigation-3/recipes/multiple-backstacks.mdmarkdown16.8 KB
references/android/guide/navigation/navigation-3/recipes/passingarguments.mdmarkdown16.0 KB
references/android/guide/navigation/navigation-3/recipes/results-event.mdmarkdown9.8 KB
references/android/guide/navigation/navigation-3/recipes/results-state.mdmarkdown9.6 KB
references/android/guide/navigation/navigation-3/recipes/scenes-listdetail.mdmarkdown15.9 KB
references/android/guide/navigation/navigation-3/recipes/scenes-twopane.mdmarkdown9.1 KB
references/android/guide/navigation/type-safe-destinations.mdmarkdown4.1 KB

references/android/guide/navigation/navigation-3/recipes/deeplinks-staticuri.md

View on GitHub
# Deep Link Static URI Recipe

This recipe demonstrates how deep link with a static Uri.

## Recipe components

The recipe contains two activities:

1. `StaticUriDeepLinkActivity` to construct and start an Intent with the deep link uri
2. `MainActivity` is the target Activity of the deep link, represents an app that users can deep link to.

## How the demonstrated deep link works

1. The deep link source (`StaticUriDeepLinkActivity`) defines the uri and creates an Intent to deep link with.
2. The app (`MainActivity`) declares a navigation key (`HomeKey`). To indicate that `HomeKey` supports deep linking, the app declares a `UriDeepLinkMatcher` with the `HomeKey` serializer along with the uri pattern that `HomeKey` supports.
3. `MainActivity` onCreate instantiates a `DeepLinkRequest` with the intent and matches it with the `UriDeepLinkMatcher` to get a `MatchResult`. If the `MatchResult` is non-null, the app navigates to the key returned by the result. Otherwise, the deep link is not supported and the app navigates to a `Fallback` screen.

[![](https://developer.android.com/static/images/picto-icons/code.svg) Explore View the full recipe on GitHub.](https://github.com/android/nav3-recipes/tree/main/app/src/main/java/com/example/nav3recipes/deeplink/handlerequests/staticuri)

```
package com.example.nav3recipes.deeplink.handlerequests.staticuri

import android.content.Intent
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.core.net.toUri
import androidx.lifecycle.compose.dropUnlessResumed
import com.example.nav3recipes.common.deeplink.EntryScreen
import com.example.nav3recipes.common.deeplink.PaddedButton
import com.example.nav3recipes.common.deeplink.TextContent
import com.example.nav3recipes.deeplink.handlerequests.uriarguments.ui.PATH_BASE
import com.example.nav3recipes.ui.setEdgeToEdgeConfig

const val HOME_URI = "$PATH_BASE/home"

class StaticUriDeepLinkActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        setEdgeToEdgeConfig()
        super.onCreate(savedInstanceState)

        setContent {
            EntryScreen("Deep link url:") {
                TextContent(HOME_URI)
                PaddedButton("Deeplink Away!", onClick = dropUnlessResumed {
                    val intent = Intent(
                        this@StaticUriDeepLinkActivity,
                        MainActivity::class.java
                    )
                    // the uri to deep link with
                    intent.data = HOME_URI.toUri()
                    startActivity(intent)
                })
            }
        }
    }
}
```

```
package com.example.nav3recipes.deeplink.handlerequests.staticuri

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.navigation3.runtime.NavBackStack
import androidx.navigation3.runtime.NavKey
import androidx.navigation3.runtime.entryProvider
import androidx.navigation3.runtime.rememberNavBackStack
import androidx.navigation3.ui.NavDisplay
import com.example.nav3recipes.common.deeplink.EntryScreen
import com.example.nav3recipes.common.deeplink.TextContent
import com.example.nav3recipes.deeplink.handlerequests.uriarguments.HomeKey
import com.example.nav3recipes.deeplink.handlerequests.uriarguments.NavRecipeKey
import androidx.navigation3.runtime.deeplink.DeepLinkRequest
import androidx.navigation3.runtime.deeplink.DeepLinkUri
import androidx.navigation3.runtime.deeplink.UriDeepLinkMatcher
import androidx.navigation3.runtime.deeplink.invoke
import com.example.nav3recipes.ui.setEdgeToEdgeConfig
import kotlinx.serialization.Serializable
import kotlinx.serialization.serializer


@Serializable
internal object FallbackKey: NavRecipeKey {
    override val name: String = "Fallback Key"
}

class MainActivity : ComponentActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        setEdgeToEdgeConfig()
        super.onCreate(savedInstanceState)

        // create a DeepLinkRequest with the intent
        val request = DeepLinkRequest(intent)

        // try to match DeepLinkRequest to a DeepLinkMatcher
        val matchResult = HOME_MATCHER.match(request)
        val key = matchResult?.key ?: FallbackKey

        /**
         * Then pass starting key to backstack
         */
        setContent {
            val backStack: NavBackStack<NavKey> = rememberNavBackStack(key)
            NavDisplay(
                backStack = backStack,
                onBack = { backStack.removeLastOrNull() },
                entryProvider = entryProvider {
                    entry<HomeKey> { key ->
                        EntryScreen(key.name) {
                            TextContent("Deep linked to Home")
                        }
                    }
                    entry<FallbackKey> { key ->
                        EntryScreen("${key.name} ") {
                            TextContent(
                                "Failed to deep link - DeepLinkRequest " +
                                    "did not match with any DeepLinkMatcher"
                            )
                        }
                    }

                }
            )
        }
    }
}

/**
 * Each matcher is associated with a navigation key that supports this deep link.
 *
 * A navigation key can be associated with multiple DeepLinkMatchers if it supports more than one deep link.
 */
private val HOME_MATCHER = UriDeepLinkMatcher(
    uriPattern = DeepLinkUri(HOME_URI),
    serializer = serializer<HomeKey>(),
)
```
slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack."Stars: 198kUpdated Claude CodeCodexVerifiedInstall
ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt.Stars: 194kUpdated Claude CodeCodexVerifiedInstall