从 link 打开应用程序的 Intent 过滤器在三星 Browser/Firefox 等中不起作用,但在 Chrome 中起作用
Intent filter for opening app from a link not working in Samsung Browser/Firefox etc. but working in Chrome
过去几个小时我一直在试验 Intent Filters,我真的很困惑为什么 Handling App Links via Intent Filters 的 Google 教程代码不能在我的三星 S8 物理设备上运行默认安装 Samsung 浏览器 或 Firefox,但可以从 Google Chrome 应用程序运行。
该代码也适用于默认的 Android Studio Nexus 5 模拟器默认浏览器应用程序以及 Google Chrome.
这是我在我试图诊断问题的准系统应用程序 AndroidManifest.xml
中的相关代码:
<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" />
<data android:scheme="https" />
<data android:host="www.android.com" />
</intent-filter>
我正在做的测试:
我在 Google 的搜索结果页面上点击了 https://www.android.com 的 link。
我希望看到一个带有我的测试应用程序名称的打开对话框,但是当我从 google chrome 浏览器(和 Nexus 5 模拟器默认浏览器)它只是自动显示没有弹出对话框的网页。
N.B. 我试过也试过以下的东西到目前为止都无济于事:
- 将第一行更改为
<intent-filter android:autoVerify="true">
- 添加行
<data android:host="www.android.com/" />
以防问题与 URL 末尾的 /
有关。
- 清除两个浏览器 data/storage 并通常将其重置。
有谁知道为什么会这样/如何解决这个问题?
浏览器本身需要支持和实现可浏览性。打开网页时,浏览器必须找到其他支持 android.intent.category.BROWSABLE
的活动。
Firefox 为用户带来了侵入性较小的体验。当打开一个 url 的 link 应用程序时,url 栏会显示一个带有小 Android 头部的页面操作。单击此按钮将使用浏览器以外的 Android activity 打开 link。
Android 浏览器的行为和 Chrome 您观察并做出了预期。所以没什么可补充的。
我不确定我是否可以完整地谈论三星浏览器,因为我设备上的版本可能已经过时了;但我根本无法让它与这些一起工作。
android:autoVerify
属性仅使该应用成为安装时的默认应用。 android:host="www.android.com/"
是错误的,因为 /
是路径而不是主机的一部分。
打开应用程序仅 link 秒
<intent-filter>
<action android:name="android.intent.action.VIEW"></action>
<category android:name="android.intent.category.DEFAULT"></category>
<category android:name="android.intent.category.BROWSABLE"></category>
<data android:scheme="spuul"></data>
</intent-filter>
有了这个,所有 URI's like spuul://movies/123 将被应用程序打开。然后应用程序能够处理此 URI 并启动正确的内容。 link 到 Google 玩像 market://details?id=com.spuul.android.
如果未安装应用程序则返回市场
<intent-filter>
<action android:name="android.intent.action.VIEW"></action>
<category android:name="android.intent.category.DEFAULT"></category>
<category android:name="android.intent.category.BROWSABLE"></category>
<data android:scheme="http" android:host="android.app.spuul.com" android:pathPrefix=""></data>
</intent-filter>
您可以通过转到三星浏览器设置 > 有用的功能 > 在其他应用程序中打开链接来解决此问题
这对您来说可能有点晚了,但希望对其他人有所帮助。
过去几个小时我一直在试验 Intent Filters,我真的很困惑为什么 Handling App Links via Intent Filters 的 Google 教程代码不能在我的三星 S8 物理设备上运行默认安装 Samsung 浏览器 或 Firefox,但可以从 Google Chrome 应用程序运行。
该代码也适用于默认的 Android Studio Nexus 5 模拟器默认浏览器应用程序以及 Google Chrome.
这是我在我试图诊断问题的准系统应用程序 AndroidManifest.xml
中的相关代码:
<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" />
<data android:scheme="https" />
<data android:host="www.android.com" />
</intent-filter>
我正在做的测试:
我在 Google 的搜索结果页面上点击了 https://www.android.com 的 link。
我希望看到一个带有我的测试应用程序名称的打开对话框,但是当我从 google chrome 浏览器(和 Nexus 5 模拟器默认浏览器)它只是自动显示没有弹出对话框的网页。
N.B. 我试过也试过以下的东西到目前为止都无济于事:
- 将第一行更改为
<intent-filter android:autoVerify="true">
- 添加行
<data android:host="www.android.com/" />
以防问题与 URL 末尾的/
有关。 - 清除两个浏览器 data/storage 并通常将其重置。
有谁知道为什么会这样/如何解决这个问题?
浏览器本身需要支持和实现可浏览性。打开网页时,浏览器必须找到其他支持 android.intent.category.BROWSABLE
的活动。
Firefox 为用户带来了侵入性较小的体验。当打开一个 url 的 link 应用程序时,url 栏会显示一个带有小 Android 头部的页面操作。单击此按钮将使用浏览器以外的 Android activity 打开 link。
Android 浏览器的行为和 Chrome 您观察并做出了预期。所以没什么可补充的。
我不确定我是否可以完整地谈论三星浏览器,因为我设备上的版本可能已经过时了;但我根本无法让它与这些一起工作。
android:autoVerify
属性仅使该应用成为安装时的默认应用。 android:host="www.android.com/"
是错误的,因为 /
是路径而不是主机的一部分。
打开应用程序仅 link 秒
<intent-filter>
<action android:name="android.intent.action.VIEW"></action>
<category android:name="android.intent.category.DEFAULT"></category>
<category android:name="android.intent.category.BROWSABLE"></category>
<data android:scheme="spuul"></data>
</intent-filter>
有了这个,所有 URI's like spuul://movies/123 将被应用程序打开。然后应用程序能够处理此 URI 并启动正确的内容。 link 到 Google 玩像 market://details?id=com.spuul.android.
如果未安装应用程序则返回市场
<intent-filter>
<action android:name="android.intent.action.VIEW"></action>
<category android:name="android.intent.category.DEFAULT"></category>
<category android:name="android.intent.category.BROWSABLE"></category>
<data android:scheme="http" android:host="android.app.spuul.com" android:pathPrefix=""></data>
</intent-filter>
您可以通过转到三星浏览器设置 > 有用的功能 > 在其他应用程序中打开链接来解决此问题
这对您来说可能有点晚了,但希望对其他人有所帮助。