【问题标题】:Android webview links open in default browserAndroid webview 链接在默认浏览器中打开
【发布时间】:2011-07-26 16:33:16
【问题描述】:

我有一个场景,我的 webview 中的链接应该打开默认的 android 浏览器。我对此进行了搜索,我知道如果我们在 webview 中设置自定义 webviewclient 并在 shouldOverrideUrlLoading 方法中加载 url,那么它将不起作用。 但就我而言,我需要在 webview 中扩展 WebviewClient,因为我正在做一些 cookie 管理并加载一些 javascript 代码。我可以知道如何同时使用这两个功能吗?

【问题讨论】:

    标签: android browser android-webview hyperlink default


    【解决方案1】:

    如果您将 WebViewClient 设置为您的 webView,您可以使用它的 onPageStartedonPageFinished 方法来执行您想要的操作。这两种方法都接收 url 作为参数,因此这允许您将此 url 发送到默认的 android webbrowser。

    startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-05-12
      • 1970-01-01
      • 1970-01-01
      • 2015-11-01
      • 1970-01-01
      • 2014-03-12
      • 1970-01-01
      • 2015-10-08
      相关资源
      最近更新 更多