我已经可以使用深层链接,但我遇到的问题是,根据 URL 中的最后一个元素,我必须将用户重定向到应用程序的不同部分。
所以现在我正在使用“http://www.mypage.com/us/en/order.html ”,但我们位于多个国家/地区,因此它也可能是“http://www.mypage.co.uk/uk/en/order.html ”。
我想要做的是捕获最后一个元素(order.html)并使用它进行深层链接。
下面是我目前拥有的,但它捕获了所有浏览器 Activity
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:launchMode="singleTask"
android:screenOrientation="portrait"
android:taskAffinity="com.mypage.app"
android:theme="@style/AppTheme"
android:windowSoftInputMode="adjustPan">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="mypagemobileapp"/>
<data android:scheme = "http"
android:host="www.mypage.com"/>
</intent-filter>
</activity>
最佳答案
查看数据元素的文档:http://developer.android.com/guide/topics/manifest/data-element.html
您可以为 url 的路径指定模式。在您的情况下,您应该使用类似以下内容
<data android:scheme="http"/>
<data android:host="www.mypage.com"/>
<data android:host="www.mypage.co.uk"/>
<data android:pathPattern=".*/.*/order\\.html"/>
匹配页面的所有国家/语言组合。如果您必须匹配其他页面,您可以相应地调整模式。
关于android - 使用 URL 结尾的深度链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35923102/