Android 深度链接两个单独的 Activity

标签 android regex android-manifest deep-linking

我有两个 Activity 要进行深层链接

一项与关注网址链接的 Activity

http://abc.or/deals

以下是它的 Intent 过滤器

      <intent-filter>
            <data
                android:host="abc.or"
                android:path="/deals"
                android:scheme="http" />
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.BROWSABLE" />
            <category android:name="android.intent.category.DEFAULT" />
       </intent-filter>

带有以下网址的另一项 Activity

http://abc.or/deals?category=Air+Conditioner-Refrigerator-
<intent-filter>
            <data
                android:host="abc.or"
                android:path="/deals"
                android:pathPattern="*deals/?category*"
                android:scheme="http" />
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.BROWSABLE" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>

但是单击任何 url 深层链接对这两个 Activity 都有效,这是我如何解决这个问题的问题

最佳答案

不幸的是,这是不可能的。
因为两个 Intent 过滤器中的路径相同。

作为替代方案,只有一个给用户的建议,

  • 从第二个 Activity 中删除 Intent 过滤器
  • 解析来自 intent.getDataString() 的 URI 数据在第一个 Activity 中并根据此数据将用户重定向到第二个 Activity 。
  • 关于Android 深度链接两个单独的 Activity ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38092119/

    相关文章:

    java - webview中的JSP/servlet处理

    regex - ansible regex_search 与变量

    r - 具有正后向捕获组的 gsub 正则表达式

    android - 如何在 searchView 中收听键盘搜索按钮

    android - 如何刷新处理程序中的待处理消息和回调

    Java 正则表达式 : Splitting based on multiple conditions with exceptions

    java - Eclipse 删除 AndroidManifest.xml 中的 Activity ?

    android-activity - 在文件夹中组织 Activity

    android - gmail 在其 list 文件中提供的权限和 Intent 列表是什么

    android - getLastKnownLocation 不是实际位置