title: How to use AsyncTask for Jsoup Parser?
body: <p>I am trying to use a AsyncTask because the the activty force closes because it takes to long on the main thread.</p>
  
  <p>Here is what i want to use in a DoInBackGround..</p>
  
  <pre><code>}
  class fetcher extends AsyncTask&lt;Void,Void, Void&gt;{
  
      @Override
      protected Void doInBackground(Void... arg0) { 
          Document doc = null;
          try {
              doc = Jsoup.connect(url).get();
          } catch (IOException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
          TextView article = (TextView)findViewById(R.id.releaseInfo);
          final TextView featuresText = (TextView)findViewById(R.id.features);
  
          // Get the overview div
          Element overview = doc.select("div#object-overview").last();
          Element featureList = doc.select("div.callout-box").last();
  
          Elements features = featureList.select("li");
          ListIterator&lt;Element&gt; featList = features.listIterator();
          while (featList.hasNext()) {
              featuresText.setText("Features: " + featList.next().text() + "\n");
  
          }
  
  
          // Get the paragraph element
          Element paragraph = overview.select("p").last();
          System.out.println(paragraph.text());
  
          article.setText(paragraph.text());
  
  
          return null;
      }
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>it always force closes i dont know why?</p>
  
  <p>EDIT: This is the debug error's i get</p>
  
  <pre><code>08-16 18:52:59.547: WARN/System.err(27209): java.net.SocketTimeoutException
  08-16 18:52:59.547: WARN/System.err(27209):     at org.apache.harmony.luni.net.PlainSocketImpl.read(PlainSocketImpl.java:564)
  08-16 18:52:59.547: WARN/System.err(27209):     at org.apache.harmony.luni.net.SocketInputStream.read(SocketInputStream.java:61)
  08-16 18:52:59.547: WARN/System.err(27209):     at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.readln(HttpURLConnectionImpl.java:1279)
  08-16 18:52:59.547: WARN/System.err(27209):     at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.readServerResponse(HttpURLConnectionImpl.java:1351)
  08-16 18:52:59.547: WARN/System.err(27209):     at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.sendRequest(HttpURLConnectionImpl.java:1339)
  08-16 18:52:59.547: WARN/System.err(27209):     at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.doRequestInternal(HttpURLConnectionImpl.java:1656)
  08-16 18:52:59.547: WARN/System.err(27209):     at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.doRequest(HttpURLConnectionImpl.java:1649)
  08-16 18:52:59.557: WARN/System.err(27209):     at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:1374)
  </code></pre>
  
  <p>More...</p>
  
  <pre><code>08-16 18:52:59.577: ERROR/AndroidRuntime(27209): FATAL EXCEPTION: AsyncTask #2
   08-16 18:52:59.577: ERROR/AndroidRuntime(27209): java.lang.RuntimeException: An error occured while executing doInBackground()
  08-16 18:52:59.577: ERROR/AndroidRuntime(27209):     at android.os.AsyncTask$3.done(AsyncTask.java:200)
  08-16 18:52:59.577: ERROR/AndroidRuntime(27209):     at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
  08-16 18:52:59.577: ERROR/AndroidRuntime(27209):     at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
  08-16 18:52:59.577: ERROR/AndroidRuntime(27209):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
  08-16 18:52:59.577: ERROR/AndroidRuntime(27209):     at java.util.concurrent.FutureTask.run(FutureTask.java:137)
  08-16 18:52:59.577: ERROR/AndroidRuntime(27209):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
  08-16 18:52:59.577: ERROR/AndroidRuntime(27209):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
  08-16 18:52:59.577: ERROR/AndroidRuntime(27209):     at java.lang.Thread.run(Thread.java:1096)
  08-16 18:52:59.577: ERROR/AndroidRuntime(27209): Caused by: java.lang.NullPointerException
  08-16 18:52:59.577: ERROR/AndroidRuntime(27209):     at com.fttech.htmlParser.HtmlparserExampleActivity$getGames.doInBackground(HtmlparserExampleActivity.java:156)
  08-16 18:52:59.577: ERROR/AndroidRuntime(27209):     at com.fttech.htmlParser.HtmlparserExampleActivity$getGames.doInBackground(HtmlparserExampleActivity.java:1)
  </code></pre>
  
  <p>The NullPointerException points to this method in the doInBackground()</p>
  
  <pre><code>                Elements games = doc.select("tr&gt;  td.indexList1, tr &gt; td.indexList2");
  </code></pre>
  
  <p>EDIT: I get this error when running it on android honeycomb </p>
  
  <pre><code>08-16 19:04:01.600: ERROR/AndroidRuntime(7302): Caused by: android.view.ViewRoot$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
  </code></pre>