【发布时间】:2016-01-21 14:01:05
【问题描述】:
我有这样的 URI:http://myapp/category/details 和 3 个应该处理此结构不同级别的活动。
活动 1 应处理 http://myapp
活动 2 应处理 http://myapp/category
活动 3 应处理 http://myapp/category/details
我在为数据标签找到正确路径/pathPattern/pathPrefix 的组合时遇到问题。在下面的示例中,所有 3 个活动都乐于处理像 http://myapp/category/details 这样的 uri,并显示“使用完成操作”对话框,其中包含 3 个 myapp 图标。
活动一:
<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="http"
android:host="myapp"
</intent-filter>
活动二:
<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="http"
android:host="myapp"
android:pathPattern="/.*"
</intent-filter>
活动 3:
<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="http"
android:host="myapp"
android:pathPattern="/.*/.*"
</intent-filter>
如何防止活动 1 处理用于活动 2 和 3 的链接?
(以及活动 2 处理活动 3 的链接)
【问题讨论】:
标签: android android-intent intentfilter deep-linking