例如,我有域 example.com
。它可以与 https
和 http
一起使用。我有这项服务的 Android 客户端。我希望客户端能够打开多种链接类型。他们在这里:
http://example.com
https://example.com
http://example.com/app
https://example.com/app
这四个应该是在ListActivity上打开的。但也有其他链接,如:
https://testask.com/i/__some_guid__
https://testask.com/item/__some_guid__
and relevant link without https
它们应该在另一个 Activity 上打开,例如 DetailsActivity。目前我有以下 DetailsActivity 的 Intent 过滤器:
<intent-filter
android:autoVerify="true"
tools:targetApi="m">
<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" />
<data android:scheme="https" />
<data
android:host="@string/root_host_endpoint"
android:pathPattern="/i/.*" />
<data
android:host="@string/root_host_endpoint"
android:pathPattern="/item/.*" />
</intent-filter>
看起来它工作正常。但我不明白,如何添加 MainActivity Intent 过滤器以指向根主机 url 并且不与 DetailsActivity Intent 过滤器重叠。
最佳答案
您可以有多个具有不同 Intent 过滤器的 Activity 。您可以使用操作/类别/数据来区分您的 Intent 过滤器。在您的情况下,您必须调整数据配置以使其处理不同的 Intent 。因此 MainActivity/ListActivity 将具有与 DetailsActivity 不同的数据配置
关于android - 如何处理不同 Activity 的应用程序链接?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44513286/