使用应用程序打开网站上的链接

Open links on a website with app

我正在为网页构建配套应用。我应该使用该应用程序在该页面上打开 links。所以我在 activity 中添加了一个意图过滤器,如下所示:

<intent-filter>
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.BROWSABLE" />
    <category android:name="android.intent.category.DEFAULT" />
    <data android:scheme="http" />
    <data android:host="www.mywebpage.com" />
    <data android:pathPrefix="/" />
</intent-filter>

当我在 Google 上搜索我的网站并单击结果时,这有效。 "open with" sheet 出现,我可以选择我的应用程序打开 link。当我在地址栏中输入 URL 到我的网站时, sheet 没有出现。然后我可以在浏览器中浏览该站点(我使用的是 Chrome),我可以单击每个 link,而不会询问我是否要使用应用程序打开 link。

有什么方法可以在单击可以用我的应用程序打开的 link 时始终显示 "open with" sheet 吗?我意识到用户可能想在浏览器中浏览该站点,当他在地址栏中明确输入 URL 时,但打开共享 sheet 是我应该实现的。

Google 似乎对 Chrome 处理 URL 的方式做了一些更改。 他们现在的政策是"If a user enters a URL into the address bar of the system, then the intention of the user is to visit the page in question. We don’t believe that the user intended to go to the app. Ergo, redirecting the user to the app is a poor user experience."

您可以在此处找到有关此主题的更多信息 - https://paul.kinlan.me/deep-app-linking-on-android-and-chrome/