无法打开深度链接URL。 这是我使用的代码
<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/app_navigation"
app:startDestination="@id/loginActivity">
<activity
android:id="@+id/passwordCreateActivity"
android:name=".PasswordCreateActivity"
android:label="password_create_activity"
tools:layout="@layout/password_create_activity">
<deepLink
app:uri="www.example.com/auth/activate/{token}" />
</activity>
</navigation>
我已经打算打开深度链接
adb shell am start -a android.intent.action.VIEW -d "www.example.com/auth/activate/2i8haFs4NqxFdzRUYoYJbq1C0?check-scheme=1" com.example.app
依赖性
implementation 'android.arch.navigation:navigation-fragment-ktx:1.0.0-alpha02'
implementation 'android.arch.navigation:navigation-ui-ktx:1.0.0-alpha02'
答案 0 :(得分:1)
我忘记在AndroidManifest文件中注册nav_graph
。
这是深度链接的完整代码。
nav_graph.xml
<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/app_navigation"
app:startDestination="@id/loginActivity">
<activity
android:id="@+id/passwordCreateActivity"
android:name=".PasswordCreateActivity"
android:label="password_create_activity"
tools:layout="@layout/password_create_activity">
<deepLink app:uri="www.example.com/auth/activate/{token}" />
</activity>
</navigation>
AndroidManifest.xml
<activity android:name=".PasswordCreateActivity">
<nav-graph android:value="@navigation/app_nav" />
</activity>