title: Android, Using an Async task to grab text from url
body: <p>Right I think as far as this goes you should consider me a complete noob, I am in way over my head.</p>
  
  <p>I have attempted to cobble what I understand about this together from several partial tutorials each dealing with a different aspect that I want to do.</p>
  
  <p>Long and short of it, all I want to do is get text read from a URL to display in a text view, my understanding is that I need an AsyncTask to do that since the 3.0 update.</p>
  
  <p>Any help on where I am going wrong would be great as I don't understand what's causing the error and how to fix.</p>
  
  <p>I do know that the code contained within the try and catch of the doInBackground works on its own before the 3.0 update. Whether this too needs to be modified to work with an Async however I don't know.</p>
  
  <p>I also imagine that other issues will probably arise once this one is sorted, if anyone spots something glaringly obvious I would be grateful if you could point it out.</p>
  
  <pre><code>String Event;
  TextView eventText;
  TextView titleText;
  
  String HTML;
  
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.newevent);
  
      titleText = (TextView) findViewById(R.id.Title);
      eventText = (TextView) findViewById(R.id.Event);
  
      new eventupdate().execute();
  
  
  }
  
  public class eventupdate extends AsyncTask&lt;String, Void, Void&gt; {
  
      @Override
      protected Void doInBackground(String... url) {
  
          try {
  
              Thread.sleep(4000);                 
  
              HttpClient httpClient = new DefaultHttpClient();
              HttpContext localContext = new BasicHttpContext();
              HttpGet httpGet = new HttpGet(
                      "http://masterzangetsu.eu/Apps/rocksoctest"); // URL!
              HttpResponse response = httpClient.execute(httpGet,
                      localContext);
              String result = "";
  
              BufferedReader reader = new BufferedReader(
                      new InputStreamReader(response.getEntity().getContent()));
  
              String line = null;
              while ((line = reader.readLine()) != null) {
                  result += line + "\n";
                  HTML = result;
              }
  
          } catch (InterruptedException e) {
  
              e.printStackTrace();
  
  
          } catch (ClientProtocolException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          } catch (IOException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
  
          eventText.setText("" + HTML);
  
          // TODO Auto-generated method stub
          return null;
      }
  
  
  }
  </code></pre>
  
  <p>And the LogCat error is:</p>
  
  <pre><code>W/dalvikvm(394): threadid=9: thread exiting with uncaught exception (group=0x40015560)
  E/AndroidRuntime(394): FATAL EXCEPTION: AsyncTask #1
  E/AndroidRuntime(394): java.lang.RuntimeException: An error occured while executing doInBackground()
  E/AndroidRuntime(394):  at android.os.AsyncTask$3.done(AsyncTask.java:200)
  E/AndroidRuntime(394):  at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:274)
  E/AndroidRuntime(394):  at java.util.concurrent.FutureTask.setException(FutureTask.java:125)
  E/AndroidRuntime(394):  at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:308)
  E/AndroidRuntime(394):  at java.util.concurrent.FutureTask.run(FutureTask.java:138)
  E/AndroidRuntime(394):  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
  E/AndroidRuntime(394):  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
  E/AndroidRuntime(394):  at java.lang.Thread.run(Thread.java:1019)
  
  E/AndroidRuntime(394): Caused by: android.view.ViewRoot$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
  
  E/AndroidRuntime(394):  at android.view.ViewRoot.checkThread(ViewRoot.java:2932)
  E/AndroidRuntime(394):  at android.view.ViewRoot.requestLayout(ViewRoot.java:629)
  E/AndroidRuntime(394):  at android.view.View.requestLayout(View.java:8267)
  E/AndroidRuntime(394):  at android.view.View.requestLayout(View.java:8267)
  E/AndroidRuntime(394):  at android.view.View.requestLayout(View.java:8267)
  E/AndroidRuntime(394):  at android.view.View.requestLayout(View.java:8267)
  E/AndroidRuntime(394):  at android.widget.ScrollView.requestLayout(ScrollView.java:1291)
  E/AndroidRuntime(394):  at android.view.View.requestLayout(View.java:8267)
  E/AndroidRuntime(394):  at android.widget.RelativeLayout.requestLayout(RelativeLayout.java:257)
  E/AndroidRuntime(394):  at android.view.View.requestLayout(View.java:8267)
  E/AndroidRuntime(394):  at android.widget.TextView.checkForRelayout(TextView.java:5521)
  E/AndroidRuntime(394):  at android.widget.TextView.setText(TextView.java:2724)
  E/AndroidRuntime(394):  at android.widget.TextView.setText(TextView.java:2592)
  E/AndroidRuntime(394):  at android.widget.TextView.setText(TextView.java:2567)
  E/AndroidRuntime(394):  at com.MasterZangetsu.kentrocksoc.nextEvent$eventupdate.doInBackground(nextEvent.java:81)
  E/AndroidRuntime(394):  at com.MasterZangetsu.kentrocksoc.nextEvent$eventupdate.doInBackground(nextEvent.java:1)
  E/AndroidRuntime(394):  at android.os.AsyncTask$2.call(AsyncTask.java:185)
  E/AndroidRuntime(394):  at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
  </code></pre>