HOW TO ANDROID WEBVIEW OPENS LINKS IN BROWSER INSTEAD OF APP?

Elena Glibart

Total Post:42

Points:296
Posted by  Elena Glibart
 1170  View(s)
Ratings:
Rate this:
Every time I click on a link in the webview, it takes me out of the webview and into a separate browser window. How do I get all the links to open in the webview?
  1. Lillian Martin

    Post:27

    Points:189
    Re: How to Android WebView Opens links in browser instead of app?

    You need to implement setWebViewClient(....) like so.

    webView.setWebViewClient(new WebViewClient() {

     

    @Override

    public boolean shouldOverrideUrlLoading(WebView view, String url) {

            view.loadUrl(url);

            return true;

            }

    });

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!