问题描述
我只想在我的应用中打开 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