title: Updating Text in UI from Async Task using onProgressUpdate
body: <p>I am using <code>AsyncTask</code> to do a http request. But the code is crashing while trying to update UI elements.</p>
  
  <pre><code>class ServerRequest extends AsyncTask&lt;String,String,String&gt; {
      private  View rootView;
      private Activity rootAct;
      private String result;
      public ServerRequest(View view,Activity act) {
          // TODO Auto-generated constructor stub\
          rootView = view;
          rootAct = act;
      }
      protected String doInBackground(String... params) {
          String URL=params[0];
          HttpClient httpclient = new DefaultHttpClient();
          HttpResponse response;
          String responseString="DEFAULT";
  
          try {
              response = httpclient.execute(new HttpGet(URL));
              StatusLine statusLine = response.getStatusLine();
              if(statusLine.getStatusCode() == HttpStatus.SC_OK){
                  ByteArrayOutputStream out = new ByteArrayOutputStream();
                  response.getEntity().writeTo(out);
                  out.close();
                  responseString = out.toString();
  
                  //..more logic
              } else{
                  //Closes the connection.
                  response.getEntity().getContent().close();
                  throw new IOException(statusLine.getReasonPhrase());
              }
          } catch (ClientProtocolException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          } catch (IOException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
  
          result = responseString;
          publishProgress(responseString);
          return  responseString;
      }
  
      @Override
      protected void onProgressUpdate(String... values) {
          // TODO Auto-generated method stub
          super.onProgressUpdate(values);
          EditText tt = (EditText) rootView.findViewById(R.id.codeResult);
          tt.setText("Sample Text"); //Causing APP TO CRASH
      }
      protected void onPostExecute(String result) {
          Log.d("retval",result);
      }
  }
  </code></pre>
  
  <p>The <code>setText</code> in <code>onProgressUpdate</code> is causing my application to crash. I have gone through most of the threads on this but couldn't find a solution.</p>
  
  <p>LOG</p>
  
  <pre><code>12-27 18:32:00.163: E/AndroidRuntime(24685):    at com.trueeduc.qrcode.ServerRequest.onProgressUpdate(ServerRequest.java:1)
  12-27 18:32:00.163: E/AndroidRuntime(24685):    at com.trueeduc.qrcode.ServerRequest.onProgressUpdate(ServerRequest.java:69)
  12-27 18:32:00.163: E/AndroidRuntime(24685):    at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:647)
  12-27 18:32:00.163: E/AndroidRuntime(24685):    at android.os.Handler.dispatchMessage(Handler.java:99)
  12-27 18:32:23.253: E/AndroidRuntime(24801):    at com.trueeduc.qrcode.ServerRequest.onProgressUpdate(ServerRequest.java:69)
  12-27 18:32:23.253: E/AndroidRuntime(24801):    at com.trueeduc.qrcode.ServerRequest.onProgressUpdate(ServerRequest.java:1)
  12-27 18:32:23.253: E/AndroidRuntime(24801):    at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:647)
  12-27 18:35:00.233: E/AndroidRuntime(24888):    at com.trueeduc.qrcode.ServerRequest.onProgressUpdate(ServerRequest.java:69)
  12-27 18:35:00.233: E/AndroidRuntime(24888):    at com.trueeduc.qrcode.ServerRequest.onProgressUpdate(ServerRequest.java:1)
  12-27 18:35:00.233: E/AndroidRuntime(24888):    at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:647)
  12-27 18:35:00.233: E/AndroidRuntime(24888):    at android.os.Handler.dispatchMessage(Handler.java:99)
  12-27 19:02:05.643: E/AndroidRuntime(25128):    at com.trueeduc.qrcode.ServerRequest.onProgressUpdate(ServerRequest.java:69)
  12-27 19:02:05.643: E/AndroidRuntime(25128):    at com.trueeduc.qrcode.ServerRequest.onProgressUpdate(ServerRequest.java:1)
  12-27 19:02:05.643: E/AndroidRuntime(25128):    at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:647)
  12-27 19:02:05.643: E/AndroidRuntime(25128):    at android.os.Handler.dispatchMessage(Handler.java:99)
  12-27 19:02:22.373: E/AndroidRuntime(25192):    at com.trueeduc.qrcode.ServerRequest.onProgressUpdate(ServerRequest.java:69)
  12-27 19:02:22.373: E/AndroidRuntime(25192):    at com.trueeduc.qrcode.ServerRequest.onProgressUpdate(ServerRequest.java:1)
  12-27 19:02:22.373: E/AndroidRuntime(25192):    at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:647)
  12-27 19:02:22.373: E/AndroidRuntime(25192):    at android.os.Handler.dispatchMessage(Handler.java:99)
  </code></pre>