的WebView链接点击打开默认浏览器 [英] WebView link click open default browser

查看:1017
本文介绍了的WebView链接点击打开默认浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在我有一个应用程序加载web视图,所有的点击量都保持在应用程序内。当达到一定的联系,例如, http://www.google.com 单击该应用程序中我想要做的就是它打开默认的浏览器。如果任何人有一些想法,请让我知道!

Right now I have an app that loads a webview and all the clicks are kept within the app. What I would like to do is when a certain link, for example, http://www.google.com is clicked within the app it opens the default browser. If anyone has some ideas please let me know!

推荐答案

我今天不得不做同样的事情,我已经发现了计算器,我想在这里分享,以防别人需要它的一个非常有用的答案。

I had to do the same thing today and I have found a very useful answer on StackOverflow that I want to share here in case someone else needs it.

<一个href="http://stackoverflow.com/questions/3583264/support-for-other-protocols-in-android-webview">Source (从斯文

webView.setWebViewClient(new WebViewClient(){
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        if (url != null && url.startsWith("http://")) {
            view.getContext().startActivity(
                new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
            return true;
        } else {
            return false;
        }
    }
});

这篇关于的WebView链接点击打开默认浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆