title: Android WebView crashes when clicking on a link
body: <p>I have some <code>WebView</code> widgets inside my <code>Activity</code>. I use <code>loadData()</code> to set the content, and this html contains a link. Some of my <code>WebViews</code> work okay, when I click the link, the web browser is started in a new window, but some make my app crash when I click on a link.</p>
  
  <pre><code>10-13 08:45:24.257: ERROR/AndroidRuntime(751): Uncaught handler: thread main exiting due to uncaught exception
  10-13 08:45:24.308: ERROR/AndroidRuntime(751): android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity  context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
  10-13 08:45:24.308: ERROR/AndroidRuntime(751):     at android.app.ApplicationContext.startActivity(ApplicationContext.java:627)
  10-13 08:45:24.308: ERROR/AndroidRuntime(751):     at android.content.ContextWrapper.startActivity(ContextWrapper.java:236)
  10-13 08:45:24.308: ERROR/AndroidRuntime(751):     at android.webkit.CallbackProxy.uiOverrideUrlLoading(CallbackProxy.java:185)
  10-13 08:45:24.308: ERROR/AndroidRuntime(751):     at android.webkit.CallbackProxy.handleMessage(CallbackProxy.java:277)
  10-13 08:45:24.308: ERROR/AndroidRuntime(751):     at android.os.Handler.dispatchMessage(Handler.java:99)
  10-13 08:45:24.308: ERROR/AndroidRuntime(751):     at android.os.Looper.loop(Looper.java:123)
  10-13 08:45:24.308: ERROR/AndroidRuntime(751):     at android.app.ActivityThread.main(ActivityThread.java:3948)
  10-13 08:45:24.308: ERROR/AndroidRuntime(751):     at java.lang.reflect.Method.invokeNative(Native Method)
  10-13 08:45:24.308: ERROR/AndroidRuntime(751):     at java.lang.reflect.Method.invoke(Method.java:521)
  10-13 08:45:24.308: ERROR/AndroidRuntime(751):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:782)
  10-13 08:45:24.308: ERROR/AndroidRuntime(751):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
  10-13 08:45:24.308: ERROR/AndroidRuntime(751):     at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p>There seems to be a problem with the <code>Intent</code> that the <code>WebView</code> fires when I click the URL, but I have no control of this <code>Intent</code>, I think.</p>
  
  <p>Does anybody have any idea?</p>
  
  <p>I use this <code>AsyncTask</code> to set the content in the <code>WebView</code>, and it works fine:</p>
  
  <pre><code>public class SetAdTask extends AsyncTask&lt;Void, Void, String&gt;{
  
      private Main main;
      private WebView webView;
  
      public SetAdTask(Main main, WebView webView){
          this.main = main;
          this.webView = webView;
      }
  
      protected void onPreExecute() {
          Main.Log("onPreExecute()");                
      }
  
      protected String doInBackground(Void... params) {
          Main.Log("doInBackground()");                
          return main.getRestClient().getAdCode();
      }
  
      protected void onPostExecute(String result) {
          Main.Log("onPostExecute()");
  
          String html = "&lt;html&gt;&lt;head&gt;&lt;title&gt;ad&lt;/title&gt;&lt;/head&gt;&lt;body&gt;";
          html += "&lt;div style=\"color:grey;font-size:12px;\"&gt;ADVERTISEMENT&lt;br/&gt;";
          html += result;
          html += "&lt;/body&gt;&lt;/html&gt;";
          webView.loadData(html, "text/html", "latin-1");
      }
  
  }
  </code></pre>