1

无法打开深层链接 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'
4

1 回答 1

4

我忘记nav_graph在 AndroidManifest 文件中注册。这是深度链接的完整代码。

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>
于 2018-07-05T16:50:20.953 回答