首页 > 解决方案 > Jetpack Compose 带有导航 backstackentry 参数和深度链接参数

问题描述

如何添加通过正常导航传递的正常参数和来自的参数

而其他深层链接将具有正常模式

可与导航和深层链接参数组合

composable(
    route = Route.Device.plus("/{Id}"),
    arguments = listOf(
        navArgument("Id") { type = NavType.StringType },
    ),
    deepLinks = listOf(navDeepLink { uriPattern = Route.Device.plus("/{Id}") }),
    content = { backStackEntry ->
        val id = backStackEntry.arguments?.getString("Id")
        DeviceScreen(
            navController = navController,
            id = id,
        )
    }
)

显现

<activity
    android:name=".MainActivity"
    android:screenOrientation="portrait"
    android:exported="true">
    <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" />

    </intent-filter>
</activity>

其他可组合的普通导航和深层链接

composable(
    route = Route.Home,
    deepLinks = listOf(navDeepLink { uriPattern = Route.Home}),
    content = { backStackEntry ->
        HomeScreen(
            navController = navController,
        )
    }
)

标签: kotlinandroid-jetpack-composejetpack-compose-navigation

解决方案


推荐阅读