title: How to update the text in the UI from the background thread in Android
body: <p>In my application I need to update the text in the UI depending upon the data from the network.For that I am using a <code>AsyncTask</code> to do work in background in Android. My code is as follows.</p>
  
  <pre><code>public class DefaultActivity extends Activity{
  
    TextView textView;
    public void onCreate(Bundle savedInstanceState){
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
      textView=(TextView)findViewById(R.id.textId);
      new networkFileAccess().execute("background","Progress","result");
    }
  
    private class networkFileAccess extends AsyncTask&lt;String,String,String&gt;{
  
      protected String doInBackground(String... background){
         return changeText();
      }
  
      private String changeText(){
       //Code to Access data from the Network.
       //Parsing the data.
       //Retrieving the boolean Value.
       if(booleanistrue){
        //Displaying some text on the UI.
        publishProgress("someTextOnUI");
        //Send request till we get get boolean value as false.
        changeText();
       }else{
         return "success";
       }
        return "";
      }
  
      protected void onProgressUpdate(String... progress){
        textView.setText("Wait background work is going on");
      }
  
      protected void onPostExecute(String result){
        if(result.equals("success")){
         //Code to finish the activity.
        }
      }
    }
  </code></pre>
  
  <p>}</p>
  
  <p>In the above code I am able to run the background thread till I get boolean value as false.But the text is not updating on the UI. Can I update the text on the UI using <code>onProgressUpdate</code>() method by calling <code>publishProgress</code> method.?Any suggesstions.    </p>