2

我有一个应用意图过滤器来打开深层链接的活动,这是我的意图过滤器:

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

                <action android:name="android.intent.action.VIEW" />

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

                <data
                    android:host="www.example.com"
                    android:pathPattern="/..*"
                    android:scheme="https" />
</intent-filter>

我的问题是,当用户从消息应用程序(例如环聊、Whatsapp)打开链接(即“www.example.com/somepage”)时,Android 应用程序选择器不会在其列表中显示可能的应用程序,它只会在选项中显示所有浏览器应用程序。但是,当用户将“ https://www.example.com/somepage ”放入消息中时,它会起作用,Android 在其应用程序选择器中显示我的应用程序以打开链接。android:scheme="https"当我尝试从我的意图过滤器中删除时,它也不起作用。

有没有人有同样的问题并有解决方案?

任何帮助都非常感谢。

4

1 回答 1

0

这是预期的行为。

以下代码段的作用是将您的应用程序注册为 URL 方案的处理程序https://

<data
    android:host="www.example.com"
    android:pathPattern="/..*"
    android:scheme="https" />

https://这意味着您的应用程序将作为任何以www.example.com. 该字符串 www.example.com/somepage不符合条件,因为它缺少该https://部分。

您可以尝试为链接添加第二个过滤器。http://我不确定Android是否会自动将其推断为未指定方案的网络链接方案,因此这可能会解决问题。

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

  <action android:name="android.intent.action.VIEW" />

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

  <data
      android:host="www.example.com"
      android:pathPattern="/..*"
      android:scheme="https" />

  <data
      android:host="www.example.com"
      android:pathPattern="/..*"
      android:scheme="http" />
</intent-filter>
于 2016-10-11T18:28:10.833 回答