我需要在我的manifest文件中使用多个主机进行应用链接,但这是行不通的。如果我在同一个意图过滤器中添加一个带有另一个主机的其他数据标签......之前工作的数据标签就不再工作了。多个意图过滤器也是如此。如果我尝试为另一个主机添加另一个意图过滤器,第一个主机(和第二个主机)就不工作了。
这里你可以看到我做了什么。
AndroidManifest.xml
<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="www.host1.com"
android:pathPattern="/path/.*"
android:scheme="https" />
</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="www.host2.com"
android:pathPattern="/path/.*"
android:scheme="https" />
</intent-filter>
如果我把host2的intent-filter删除,host1就可以工作了!
任何想法?
试着把这个意图过滤器添加到与其他活动不同的活动中,或者试着为每个主机名创建多个虚拟入口点。
我知道这并不理想,但它会做的伎俩。
也可以参考这里了解更多如何实现。
https:/developer.android.comtrainingapp-linksverify-site-associations。
例如:
<activity android:name=”MainActivity”>
<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:scheme="http" android:host="www.example.com" />
<data android:scheme="https" />
</intent-filter>
</activity>
<activity android:name=”ShadowActivity1”>
<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="https" android:host="www.example.net" />
</intent-filter>
</activity>
<activity android:name=”ShadowActivity2”>
<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="https" android:host="www.example123332.net"/>
</intent-filter>
</activity>