Android Deeplink URL 端点处理

问题描述

我只想在我的应用中打开 url 的特定端点,并在浏览器中休息。

我有以下网址端点:

/users/sign_in - (应该在应用程序中打开) - 工作

/users/password/edit - (应该在应用程序中打开) - 工作

/users/invitation/accept - (应该在浏览器中打开) - 这个 url 打开应用程序,但我不想为此端点打开我的应用程序

下面是我的 Manifest.xml

<activity
        android:name=".activity.SetNewPasswordActivity"
        android:launchMode="singleTask">
        <intent-filter android:autoVerify="true">
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.broWSABLE" />

            <data
                android:host="test.host.com"
                android:pathPattern="/users/password/edit"
                android:scheme="https" />
        </intent-filter>
    </activity>
    <activity
        android:name=".activity.ActivitySplash"
        android:screenorientation="portrait">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <intent-filter android:autoVerify="true">
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.broWSABLE" />

            <data
                android:host="test.host.com"
                android:path="/users/sign_in"
                android:scheme="https" />
        </intent-filter>
    </activity>

解决方法

您可以通过使用 pathPrefix 而不是 path 来定位特定路径来做到这一点,<data android:host = "test.host.com" android:pathPrefix = "/users/sign_in" android:scheme = "https" /> <data android:host = "test.host.com" android:pathPrefix = "/users/password/edit" android:scheme = "https" /> 检查路径是否以提到的前缀开头

url_for

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...