用于从无法在Samsung Browser/Firefox等中运行但在Chrome中运行的链接打开应用程序的意图过滤器 [英] Intent filter for opening app from a link not working in Samsung Browser/Firefox etc. but working in Chrome

查看:206
本文介绍了用于从无法在Samsung Browser/Firefox等中运行但在Chrome中运行的链接打开应用程序的意图过滤器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在过去的几个小时中,我一直在尝试使用Intent过滤器,但对于为什么

I have been experimenting with the Intent Filters for the past few hours, and I am really confused as to why the Google tutorial code for Handling App Links via Intent Filters is not working on my physical Samsung S8 devices's default Samsung browser or Firefox installed on it however working from the Google Chrome app.

该代码还可以在默认的Android Studio Nexus 5的模拟器默认浏览器应用程序以及Google Chrome中使用.

The code also works both in the default Android Studio Nexus 5's emulator default browser app as well as from Google Chrome.

这是我正在尝试诊断问题的准系统应用程序的AndroidManifest.xml中的相关代码:

Here is the relevant code I have in the AndroidManifest.xml of the bare-bones app I am trying to diagnose the problem with:

<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>

我要测试的内容:

我从搜索结果页上点击 https://www.android.com 的链接Google.

I click on a link for https://www.android.com from a search results page on Google.

我希望看到一个带有我的测试应用程序名称的打开对话框,但是当我尝试使用Google chrome浏览器(和Nexus 5仿真器默认浏览器)进行任何操作时,该对话框均不会显示,它会自动显示没有任何提示的网页弹出对话框.

I expect to see a open with dialog with my test apps name however it does not show when I try this from anything but the the google chrome browser (and the Nexus 5 emulators default browser) it just automatically shows the webpage with no popup dialog.

NB 我到目前为止还尝试了以下操作,但无济于事:

N.B. I have tried also tried the following things so far to no avail:

  • 将第一行更改为<intent-filter android:autoVerify="true">
  • 如果出现问题与URL末尾的/有任何关系,请添加行<data android:host="www.android.com/" />.
  • 清除两个浏览器的数据/存储&通常会重置它.
  • Changing the first line to <intent-filter android:autoVerify="true">
  • Adding the line <data android:host="www.android.com/" /> in case the the problem has anything to do with the / at the end of URL.
  • Clearing the both browsers data/storage & generally resetting it.

有人知道为什么会这样/如何解决吗?

推荐答案

浏览器本身需要支持和实现可浏览性.浏览器在打开网页时必须找到其他支持android.intent.category.BROWSABLE的活动.

The browsers itself need to support and implment the browsability. The browsers have to find other activities supporting android.intent.category.BROWSABLE when opening a web-page.

Firefox对用户的侵入性较小.当打开具有指向应用程序的深层链接的URL时,URL栏将显示带有一个Android小标题的页面操作.单击此链接将打开一个带有浏览器以外的Android活动的链接.

Firefox implements a less invasive experience to the user. When an url is opened which has a deep link to an app, the url bar displays a page action with a little Android head. Clicking on this one will open the link with an Android activity other than a browser.

您观察并做出期望的Android浏览器和Chrome的行为.所以没什么可补充的.

The behavior of the Android browser and Chrome you observed and made your expectation. So nothing to add to this.

我不确定我是否可以全面谈论三星浏览器,因为我设备上的版本可能已经过时;但我根本无法使用它们.

I'm not sure if I can fully talk about the Samsung browser, because the versions I have on my devices might be somehow outdated; but I couldn't make it work with these at all.

android:autoVerify属性仅使应用程序成为安装时的默认设置. android:host="www.android.com/"只是错误的,因为/是路径而不是主机的一部分.

The android:autoVerify attribute only makes the app the default on installation. android:host="www.android.com/" is just wrong, because / is the path and not part of the host.

这篇关于用于从无法在Samsung Browser/Firefox等中运行但在Chrome中运行的链接打开应用程序的意图过滤器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆