从URL打开应用程序适用于Android版Firefox但不适用于谷歌浏览器

Kli*_*akM 6 firefox android google-chrome intentfilter

我想在用户点击我的网页链接时打开我的Android应用程序(最好是从Facebook分享帖子,但让我们从普通网址开始).

为此,我创建了一个Activity UrlReceiver并将此代码添加到我的AndroidManifest.xml文件中(URL仅用于测试目的):

<activity
        android:name=".main.core.UrlReceiver"
        android:exported="true">
        <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:host="martinfowler.com"
                android:pathPrefix="/"
                android:scheme="http"/>
            <data
                android:host="www.martinfowler.com"
                android:pathPrefix="/"
                android:scheme="http"/>
            <data
                android:host="test"
                android:scheme="myapp"/>
        </intent-filter>
</activity>
Run Code Online (Sandbox Code Playgroud)

这是适用于Android的Firefox,当我输入myapp://test/它时会自动打开我的应用程序,当我进入时martinfowler.com,网址旁边有一个Android头,可以点按我的应用程序.这很好.

但它不适用于谷歌浏览器.当我进入myapp://test/它开始谷歌搜索时,当我输入martinfowler.com它只是打开网页.

我开始在网上挖掘这个并发现这个文档:https://developer.chrome.com/multidevice/android/intents,打开自定义模式不再适用于Chrome,所以我尝试使用这个URL(根据文献):

intent://test/#Intent;scheme=myapp;package=com.my.app;end
intent://#Intent;scheme=myapp;package=com.my.app;end
intent://test/#Intent;package=com.my.app;scheme=myapp;end
intent://#Intent;package=com.my.app;scheme=myapp;end
Run Code Online (Sandbox Code Playgroud)

但这些也开始谷歌搜索.我该怎么办,从谷歌浏览器中的URL打开我的应用程序?

我已经在KitKat和Lolipop上测试了这个.

Kli*_*akM 5

问题是我一直在将键盘输入(或复制)到Chrome Omnibox(搜索栏)并根据此问题:https://code.google.com/p/chromium/issues/detail?id = 451956它不是支持时间更长

http://crbug.com/331571中,如果原始导航是从用户输入开始的,我们决定不启动Intent,因为我们认为通常用户在多功能框中键入URL时不会希望离开Chrome.

因此,从Google Chrome中的网址打开应用仅适用于链接点按,并且在使用搜索栏时无效.