簡體   English   中英

從URL打開應用程序適用於Android版Firefox但不適用於谷歌瀏覽器

[英]Open App from URL works on Firefox for Android but not on Google Chrome

我想在用戶點擊我的網頁鏈接時打開我的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>

這是在Android for Firefox上工作,當我輸入myapp://test/它會自動打開我的應用程序,當我進入martinfowler.com時,在url旁邊有一個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

但這些也開始谷歌搜索。 我該怎么辦,從谷歌瀏覽器中的URL打開我的應用程序?

我已經在KitKat和Lolipop上測試了這個。

問題是我一直在將鍵盤輸入 (或復制 )到Chrome Omnibox(搜索欄)並根據此問題: https//code.google.com/p/chromium/issues/detail?id = 451956它不是支持時間更長

http://crbug.com/331571中,如果原始導航是從用戶輸入開始的,我們決定不啟動Intent,因為我們認為通常用戶在多功能框中鍵入URL時不會希望離開Chrome。

因此,從Google Chrome中的網址打開應用僅適用於鏈接點按,並且在使用搜索欄時無效。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM