0

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.

Srikanth
  • 1,555
  • 12
  • 20
  • Why are you creating a WebView inside your WebView here? `@Override public boolean onCreateWindow(WebView view, boolean isDialog, boolean isUserGesture, Message resultMsg) { WebView newWebView = new WebView(MainActivity.this); ... }` You should create a single WebView inside your Fragment/Activity. Creating multiple WebViews will open a Pandora's box of a whole lot of potential issues. – susosaurus Aug 12 '22 at 07:25
  • To load url in same webview, we can't use this code. Above code will open url in new webview inside a dialog. Also https://stackoverflow.com/a/58386309 – Srikanth Aug 12 '22 at 07:44

0 Answers0