title: AsyncTask cannot work in thread android
body: <p>I use AsyncTask to change text of TextView like this:</p>
  
  <pre><code>    private class LongOperation extends AsyncTask&lt;String, Void, String&gt; {
      @Override
      protected String doInBackground(String... urls) {
          String response = "";
          for (String url : urls) {
              response += url;
          }
          return response;
      }
  
      @Override
      protected void onPostExecute(String result) {
          textView.setText(result);
      }
  }
  </code></pre>
  
  <p>Everything will fine if I call it in OnClick event:</p>
  
  <pre><code> public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      textView = (TextView) findViewById(R.id.txt);
      Button button = (Button)this.findViewById(R.id.button);
      button.setOnClickListener(new OnClickListener() {
          @Override
          public void onClick(View v) {
            new LongOperation().execute(new String[]{"Hello"});
          }
        });
     }
  </code></pre>
  
  <p>But the problem when I called it in my thread, the program forced close</p>
  
  <pre><code>this.closeButton.setOnClickListener(new OnClickListener() {
           @Override
          public void onClick(View v) {
            Thread t= new Thread(){               
             @Override
               public void run(){                                     
                try{
                      //Do something
                      //Then call AsyncTask
                  new LongOperation().execute(new String[]{"Hello"});
  
                 }catch(Exception e){}
           }
          };      
           t.start();
          }
        });
  </code></pre>
  
  <p>Where am I wrong? I dont' understand how difference call AsyncTask in thread or not. </p>