Open url in parent webview with out creating a new webview in android

376 Views Asked by At

I have an webpage which contain login button in it, On click of this login button it's opening new tab in Chrome. I tried to load this webpage in my Webview, like in below code.

@Override
    public boolean onCreateWindow(WebView parentWebView, boolean isDialog, boolean isUserGesture, Message resultMsg) {
        WebView chileWebView = new WebView(mContext);
        chileWebView.getSettings().setJavaScriptEnabled(true);
        chileWebView.setWebViewClient(...);
        parentWebView.addView(chileWebView, new WindowManager.LayoutParams(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT));
        ((WebView.WebViewTransport)resultMsg.obj).setWebView(chileWindowWebView);
        resultMsg.sendToTarget();
        return true;
    }

But I need to load new url in same parentWebView. Is there any possibility to load this directly in to parentWebView like below without creating new childWebview?

((WebView.WebViewTransport)resultMsg.obj).setWebView(parentWebView);

When I set webView.getSettings().setSupportMultipleWindows(false); it's loading about:blank page on click of login button.

0

There are 0 best solutions below