title: Completely stop an android webview
body: <p>I have an android webview and allow the user to use their own javascript inside a window.onload callback (its completely isolated and I personally don't see a security risk). The problem occurs if something like the following is entered</p>
  
  <pre><code>while(true){
  }
  </code></pre>
  
  <p>In the java side of things, I start a timer and after about 5 seconds if JavaScript is still going I try to stop the webview. I have tried various things:</p>
  
  <pre><code>webView.stopLoading();
  webView.loadData("", "text/html", null);
  webView.freeMemory();
  webView.pauseTimers();
  webView.destroy();
  Class.forName("android.webkit.WebView").getMethod("onPause", (Class[]) null).invoke(webView, (Object[]) null);
  </code></pre>
  
  <p>each one getting a little more desperate :). Nothing works and a thread continues to use up the processor until I quit the app. Does anyone know how I can stop it correctly?</p>
  
  <p>Any help is much appreciated,
  Ian</p>