Carla Dessi Carla Dessi - 1 year ago 99
Java Question

android webview stay in app

I have a webview in my android app, but when someone navigates around the site, it opens in a new window, i want it to stay inside the webview.. is there a way to do this easily? Here is the code in my activity:

WebView webview;
webview = (WebView) findViewById(;

Answer Source

You'll have to create a WebViewClient:

public class myWebViewClient extends WebViewClient {
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        return true;

And then set it to your WebView like this:

webview.setWebViewClient(new myWebViewClient());
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download