【发布时间】:2016-06-29 08:17:28
【问题描述】:
我想从我的 Cordova 应用程序中使用 Google Chrome(而不是其他浏览器)打开一个链接。我尝试了几种解决方案,但没有任何效果。
首先,我尝试创建指向googlechrome:// 的链接(使用HTML <a> 标记)。它会打开 Google Chrome,但我无法选择要打开的 URL。
然后,我尝试创建指向intent://my.url.com/#Intent;scheme=https;package=com.android.chrome;end 的链接。此链接在我从浏览器(如 Firefox 或 Google Chrome)打开时有效,但在我从 Cordova 应用程序中打开时无效。
我也尝试过使用cordova-webintent 插件,就像这样:
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 Intent 打开 URL” 错误。
我该怎么办?
PS : 我在 config.xml 文件中写了<allow-intent href="*" />。
【问题讨论】:
标签: android cordova google-chrome