Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android WebView Opens links in browser instead of app [duplicate]

I followed this tutorial: http://examples.javacodegeeks.com/android/core/ui/webview/android-webview-example/

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?

like image 832
Katie H Avatar asked Dec 14 '25 07:12

Katie H


1 Answers

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

webView.setWebViewClient(new WebViewClient() {

@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
        view.loadUrl(url);
        return true;
        }
});
like image 99
M D Avatar answered Dec 16 '25 23:12

M D



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!