title: webview not closing onclosewindow
body: <p>I managed to create a glorious webview app, and running into some challenges:</p>
  
  <p>popup window opens in newwebview, for example a comm100 chat window, sadly I can't get the window to close when chat is finished. not sure what to add to the onPageFinished() and or onCloseWindow()</p>
  
  <p>Any help is much appreciated.</p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
  private WebView webView;
  
  @SuppressLint("SetJavaScriptEnabled")
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      webView=(WebView) findViewById(R.id.view1);
      webView.loadUrl("https://comm100.com");
      WebSettings webSettings = webView.getSettings();
      webSettings.setJavaScriptEnabled(true);
      webSettings.setDomStorageEnabled(true);
      webSettings.setSupportMultipleWindows(true);
      webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
      webSettings.setAllowFileAccess(true);
      webSettings.setAllowContentAccess(true);
      webSettings.setAllowUniversalAccessFromFileURLs(true);
      webSettings.setAllowFileAccessFromFileURLs(true);
      webView.setWebViewClient(new WebViewClient());
      webView.setWebChromeClient(new WebChromeClient(){
  
          @Override
          public boolean onCreateWindow(WebView view, boolean isDialog, boolean isUserGesture, Message resultMsg) {
              final WebView newWebview = new WebView(MainActivity.this);
              newWebview.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
              WebSettings webSettings1 = newWebview.getSettings();
              webSettings1.setJavaScriptEnabled(true);
              webSettings1.setDomStorageEnabled(true);
              webSettings1.setSupportMultipleWindows(true);
              webSettings1.setJavaScriptCanOpenWindowsAutomatically(true);
              webSettings1.setAllowFileAccess(true);
              webSettings1.setAllowContentAccess(true);
              webSettings1.setAllowUniversalAccessFromFileURLs(true);
              webSettings1.setAllowFileAccessFromFileURLs(true);
              view.addView(newWebview);
              WebView.WebViewTransport transport = (WebView.WebViewTransport) resultMsg.obj;
              transport.setWebView(newWebview);
              resultMsg.sendToTarget();
              newWebview.setWebViewClient(new WebViewClient(){
  
                  @Override
                  public boolean shouldOverrideUrlLoading(WebView view, String url) {
                      view.loadUrl(url);
                      return true;
                  }
                  @Override
                  public void onPageFinished(WebView view, String url){
                      super.onPageFinished(view, url);
                  }
  
              });
              //return super.onCreateWindow(view, isDialog, isUserGesture, resultMsg);
              return true;
          }
  
          @Override
          public void onCloseWindow(WebView window) {
              super.onCloseWindow(window);
          }
      });
  
  }
  
  
  @Override
  public void onBackPressed() {
      if (webView.canGoBack()){
          webView.goBack();
      } else {
      super.onBackPressed();
      }
  }
  }
  </code></pre>
  
  <p>Logcat shows the following error</p>
  
  <pre><code>I/chromium: [INFO:CONSOLE(8)] "Uncaught (in promise) #&lt;Object&gt;", source: https://chatserver.comm100.com/js/bundle.4273ade4b401f37d4797b68863b403e6.js (8)
  </code></pre>
  
  <p>check out video example <a href="https://gfycat.com/WhisperedWastefulKrill" rel="nofollow noreferrer">Video Link</a></p>