[英]Intent filter for opening app from a link not working in Samsung Browser/Firefox etc. but working in Chrome
在过去的几个小时里,我一直在试验意图过滤器,我真的很困惑为什么通过意图过滤器处理应用程序链接的 Google 教程代码在我的物理三星 S8 设备的默认三星浏览器或安装在上面的 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的链接。
我希望看到一个带有我的测试应用程序名称的打开对话框,但是当我从 google chrome 浏览器(和 Nexus 5 模拟器默认浏览器)之外的任何东西尝试这个时它不会显示它只是自动显示没有弹出对话框的网页。
注意,到目前为止,我也尝试过以下操作无济于事:
<intent-filter android:autoVerify="true">
<data android:host="www.android.com/" />
以防问题与 URL 末尾的/
有关。有谁知道为什么会这样/如何解决这个问题?
浏览器本身需要支持和实现可浏览性。 打开网页时,浏览器必须找到其他支持android.intent.category.BROWSABLE
活动。
Firefox 为用户提供了一种侵入性较小的体验。 当打开一个带有应用程序深层链接的 url 时,url 栏会显示一个带有小 Android 头的页面操作。 单击此按钮将打开带有浏览器以外的 Android 活动的链接。
您观察到的 Android 浏览器和 Chrome 的行为并做出了您的期望。 所以没有什么可以补充的。
我不确定我是否可以完整地谈论三星浏览器,因为我设备上的版本可能已经过时了; 但我根本无法让它与这些一起工作。
android:autoVerify
属性仅使应用程序成为安装时的默认设置。 android:host="www.android.com/"
是错误的,因为/
是路径而不是主机的一部分。
仅为某些链接打开应用程序
<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 像 spuul://movies/123 将被应用程序打开。 然后,该应用程序能够处理此 URI 并启动正确的内容。 Google Play 的链接,如 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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.