title: Android WebChromeClient onCloseWindow not working
body: <p>I have a simple android app that opens a webview to call a web application.<br>
  I want to close the entire android app when the web application has a window.close();</p>
  
  <p>I also want the back key to navigate back through the web pages, and that is working.</p>
  
  <p>The window is closing, but the application is not closing and the log is not being updated.   I think the onWindowClose is not being triggered for some reason.</p>
  
  <p>This is my android app -</p>
  
  <pre><code>import java.util.HashMap;
  import java.util.Map;
  
  import android.app.Activity;
  import android.content.Intent;
  import android.util.Log;
  import android.view.KeyEvent;
  
  import android.os.Bundle;
  import android.webkit.WebChromeClient;
  import android.webkit.WebView;
  import android.webkit.WebViewClient;
  public class MainActivity extends Activity {
  
  protected static final String TAG = null;
  private WebView webView;
  
  
  @Override
  public boolean onKeyDown(int keyCode, KeyEvent event) {
      if(event.getAction() == KeyEvent.ACTION_DOWN){
          switch(keyCode)
          {
          case KeyEvent.KEYCODE_BACK:
              if(webView.canGoBack()){
                  webView.goBack();
              }else{
                  finish();
              }
              return true;
          }
  
      }
      return super.onKeyDown(keyCode, event);
  }
  
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      Map&lt;String,String&gt; extraHeaders = new HashMap&lt;String, String&gt;();
      extraHeaders.put("X-Requested-With", "MY-App");
  
  
      //webview use to call own site
      webView = (WebView) findViewById(R.id.webView1);
      webView.setWebViewClient(new WebViewClient()); //use to hide the address bar      
      webView .getSettings().setJavaScriptEnabled(true);     
      webView .getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
      webView .getSettings().setDomStorageEnabled(true); //to store history  
      webView.setWebViewClient(new WebViewClient()); 
      webView.loadUrl("http://www.Google.com",extraHeaders); 
  
      WebChromeClient wbc = new WebChromeClient(){
  
  
          public void onCloseWindow(WebView webView){
              super.onCloseWindow(webView);
  
              Log.d(TAG, "Window trying to close");
              Intent intent = new Intent(getApplicationContext(), MainActivity.class);
              intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
              startActivity(intent);
              finish();
  
          }
  
    };
  
  
    webView.setWebChromeClient(wbc);
  
   ;
  
  
   } 
  </code></pre>
  
  <p>Here is the Manifest.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.example.google"
  android:versionCode="1"
  android:versionName="1.0" 
  &lt;uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="16" /&gt;
  
  &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
  
  &lt;application
      android:allowBackup="true"
      android:icon="@drawable/ic_launcher"
      android:label="@string/Google"
      android:theme="@style/AppTheme" 
      android:noHistory="true"
      android:excludeFromRecents="true"
       &gt;
  
      &lt;activity
          android:name="com.example.google.MainActivity"
          android:label="@string/app_name" 
          android:clearTaskOnLaunch="true"
          android:configChanges="orientation|keyboard|keyboardHidden|screenSize"&gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.MAIN" /&gt;
  
              &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
          &lt;/intent-filter&gt;
    &lt;/activity&gt;
    &lt;/application&gt;
  
  &lt;/manifest&gt;'
  </code></pre>
  
  <p>Thanks for all your help!</p>