Android 科尔多瓦:使用谷歌浏览器打开链接

Android 科尔多瓦:使用谷歌浏览器打开链接,android,cordova,google-chrome,Android,Cordova,Google Chrome,我想从我的Cordova应用程序中使用Google Chrome(而不是其他浏览器)打开一个链接。我尝试了几种解决方案,但都不管用 首先,我尝试创建一个到googlechrome://的链接(使用HTML插件,如下所示: window.plugins.webintent.startActivity( { action: window.plugins.webintent.ACTION_VIEW, url: 'intent://my.url.com/#Inte

我想从我的Cordova应用程序中使用Google Chrome(而不是其他浏览器)打开一个链接。我尝试了几种解决方案,但都不管用

首先,我尝试创建一个到
googlechrome://
的链接(使用HTML
插件,如下所示:

window.plugins.webintent.startActivity(
    {
        action: window.plugins.webintent.ACTION_VIEW,
        url: 'intent://my.url.com/#Intent;scheme=https;package=com.android.chrome;end'
    },
    function() {
        alert(url);
    },
    function(){
        alert('Failed to open URL via Android Intent');
    }
);
但我得到了一个“无法通过Android意图打开URL”错误

我该怎么办

PS:我在config.xml文件中编写了

您可以将
\u系统
用作目标:

cordova.InAppBrowser.open('http://stackoverflow.com', '_system', 'location=yes');
或者您可以使用(不知道这是否与您使用的相同),如下所示:

window.plugins.webintent.startActivity({
        action: window.plugins.webintent.ACTION_VIEW,
        url:  "googlechrome://navigate?url=http://www.stackoverflow.com"
    },
    function() {},
    function() {
        alert('Failed to open URL via Android Intent.');
      console.log("Failed to open URL via Android Intent.")
    });

url必须以http或https开头,它不允许相对url。

我终于找到了解决方案。我只需要创建一个类似以下的链接:


谢谢您的回答。第一个解决方案不起作用,因为它会询问用户选择什么浏览器,而这不是我想要的。但是,您发布的代码片段帮助我理解了未记录的
谷歌浏览器://
URL方案,我找到了一个使用它的简单解决方案(请参阅我的答案).谢谢!我给你奖金是因为你帮了我很多忙才找到答案:)如果是谷歌地图链接,你想强制使用chrome vs maps应用程序,上面的
应用浏览器
选项将不起作用。如果用户想使用“地图”或Chrome打开链接,手机会提示用户,如果用户已经默认使用“地图”,手机只需绕过该问题并在“地图”中自动打开,就无法实现强制在Chrome中打开链接的目的。