title: How to instantiate AsyncTask
body: <pre><code>package com.markana.yamba;
  
  import winterwell.jtwitter.Twitter;
  import winterwell.jtwitter.TwitterException;
  import android.app.Activity;
  import android.graphics.Color;
  import android.os.AsyncTask;
  import android.os.Bundle;
  import android.text.Editable;
  import android.text.TextWatcher;
  import android.util.Log;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.widget.Button;
  import android.widget.EditText;
  import android.widget.TextView;
  import android.widget.Toast;
  
  public class StatusActivity2 extends Activity implements OnClickListener{
      private static final String TAG= "StatusActivity";
      EditText editText;
      Button updateButton;
      TextView textCount;
      Twitter twitter;
  
  
      /** Called when the activity is first created. */
      @SuppressWarnings("deprecation")
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.status);
          //Finds views
          editText =(EditText) findViewById(R.id.editText);
          updateButton=(Button) findViewById(R.id.buttonUpdate);
          updateButton.setOnClickListener(this);
  
  
  
          twitter=new Twitter("student","password");
          twitter.setAPIRootUrl(("http://yamba.marakana.com/api"));   
  
      }
  
      public void onClick(View arg0) {
          // TODO Auto-generated method stub
          String status=editText.getText().toString();
          new PostToTwitter().execute(status);
          Log.d(TAG, "onClick");
      }
  
      class PostToTwitter extends AsyncTask&lt;String,Integer, String&gt;
      {
          @Override
          protected String doInBackground(String... statuses) {
  
              try{
              Twitter.Status status=twitter.updateStatus(statuses[0]);
              return status.text;
              }
              catch(TwitterException e)
              {
                  Log.e(TAG,e.toString());
                  e.printStackTrace();
                  return "Failed to post";
              }
          }
  
  
          protected void onProgressUpdate(Integer...values)
          {
                 super.onProgressUpdate(values);
          }
  
          protected void onPostExecute(String result)
          {
              Toast.makeText(StatusActivity2.this,result,Toast.LENGTH_LONG).show();           
          }
      }
  
  
  
  
  
  }
  </code></pre>
  
  <p>i get two exceptions relating to Async task</p>
  
  <p>thats what i did. it tells me that i have a problem when i run the background worker!!</p>
  
  <pre><code>04-20 09:21:32.553: ERROR/AndroidRuntime(838): FATAL EXCEPTION: AsyncTask #1
  04-20 09:21:32.553: ERROR/AndroidRuntime(838): java.lang.RuntimeException: An error occured while executing doInBackground()
  04-20 09:21:32.553: ERROR/AndroidRuntime(838):     at android.os.AsyncTask$3.done(AsyncTask.java:200)
  04-20 09:21:32.553: ERROR/AndroidRuntime(838):     at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
  04-20 09:21:32.553: ERROR/AndroidRuntime(838):     at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
  04-20 09:21:32.553: ERROR/AndroidRuntime(838):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
  04-20 09:21:32.553: ERROR/AndroidRuntime(838):     at java.util.concurrent.FutureTask.run(FutureTask.java:137)
  04-20 09:21:32.553: ERROR/AndroidRuntime(838):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
  04-20 09:21:32.553: ERROR/AndroidRuntime(838):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
  04-20 09:21:32.553: ERROR/AndroidRuntime(838):     at java.lang.Thread.run(Thread.java:1096)
  04-20 09:21:32.553: ERROR/AndroidRuntime(838): Caused by: java.lang.IllegalArgumentException
  04-20 09:21:32.553: ERROR/AndroidRuntime(838):     at java.util.Date.parse(Date.java:447)
  04-20 09:21:32.553: ERROR/AndroidRuntime(838):     at java.util.Date.&lt;init&gt;(Date.java:157)
  04-20 09:21:32.553: ERROR/AndroidRuntime(838):     at winterwell.jtwitter.Twitter$Status.&lt;init&gt;(Twitter.java:659)
  04-20 09:21:32.553: ERROR/AndroidRuntime(838):     at winterwell.jtwitter.Twitter.updateStatus(Twitter.java:3231)
  04-20 09:21:32.553: ERROR/AndroidRuntime(838):     at winterwell.jtwitter.Twitter.updateStatus(Twitter.java:3161)
  04-20 09:21:32.553: ERROR/AndroidRuntime(838):     at com.markana.yamba.StatusActivity2$PostToTwitter.doInBackground(StatusActivity2.java:60)
  04-20 09:21:32.553: ERROR/AndroidRuntime(838):     at com.markana.yamba.StatusActivity2$PostToTwitter.doInBackground(StatusActivity2.java:1)
  04-20 09:21:32.553: ERROR/AndroidRuntime(838):     at android.os.AsyncTask$2.call(AsyncTask.java:185)
  04-20 09:21:32.553: ERROR/AndroidRuntime(838):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
  04-20 09:21:32.553: ERROR/AndroidRuntime(838):     ... 4 more
  </code></pre>
  
  <p>it should pop a message in the end.. as you can see in the method onClick!</p>