【问题标题】:Force chrome out of webview (on android)强制 chrome 退出 webview(在 android 上)
【发布时间】:2018-04-23 11:25:30
【问题描述】:

我想知道是否有办法强制打开 chrome 从 android webview(使用 js、php)到特定 URL?

澄清一下,如果有人在具有 webview 活动的应用程序(例如 Skype 移动版)中单击所述链接,该链接将导致 chrome 启动到该链接而不是 webview 活动(或者甚至首先启动 webview 活动然后移动到 chrome )。

我知道我可以通过检查 UA 字符串中的子字符串“版本”来检测客户端是否为 webview,但我不熟悉任何有意从 URL 或 js 启动特定浏览器的方法。

提前致谢!

【问题讨论】:

标签: javascript php google-chrome webview


【解决方案1】:

是的,你可以这样做,在 android 中:

String url = "https://google.com";
try {
    Intent i = new Intent("android.intent.action.MAIN");
    i.setComponent(ComponentName.unflattenFromString("com.android.chrome/com.android.chrome.Main"));
    i.addCategory("android.intent.category.LAUNCHER");
    i.setData(Uri.parse(url));
    startActivity(i);
}
catch(ActivityNotFoundException e) {
    // Chrome is not installed
    Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
    startActivity(i);
}

【讨论】:

  • 假设我无法控制 android 代码。有没有办法用 JS/php 做到这一点?
  • 您使用的是哪个框架,如果它是混合的,请告诉我们...并将其添加到您的问题中...
  • 是的,有可能...等一下,让我为你写一个快速破解
  • 请试试这个<a onclick=\"window.open('someurl.html', '_system');\"> 工作正常!在两个平台上!
  • 这不是一个android开发问题,因为我无法控制应用程序的代码,因此我必须使用web编程语言(如js、php等)。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-01-30
  • 2015-05-28
  • 1970-01-01
  • 2017-04-06
  • 1970-01-01
  • 2012-12-01
相关资源
最近更新 更多