我正在尝试添加指向 May 导航的深层链接,但它没有打开导航,而是重新启动应用程序并启动主要活动。这是我的导航图:
<?xml version="1.0" encoding="utf-8"?>
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/navigation_main"
app:startDestination="@id/fragmentMain">
<fragment
android:id="@+id/fragmentMain"
android:name="com.straiberry.app.features.main.presentation.view.main.FragmentMain"
android:label="FragmentMain"
tools:layout="@layout/fragment_main" >
<deepLink
android:id="@+id/deepLink"
app:uri="mayapp:/auth?access={access}&refresh={refresh}#" />
<argument
app:argType="string"
android:name="access"
android:defaultValue=""/>
<argument
app:argType="string"
android:name="refresh"
android:defaultValue=""/>
</fragment>
</navigation>
这是我在清单中的活动,我添加了导航:
<activity
android:name=".MainActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize"
>
<nav-graph android:value="@navigation/navigation_main"/>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
这是启动url的代码:
private fun goToUrl(url: String) {
val builder: CustomTabsIntent.Builder = CustomTabsIntent
.Builder()
.setColorScheme(CustomTabsIntent.COLOR_SCHEME_SYSTEM)
val customTabsIntent: CustomTabsIntent = builder.build()
customTabsIntent.launchUrl(requireActivity(), Uri.parse(url))
}
有人可以帮忙吗?我做错了什么?