title: NullPointerException while calling AsyncTask.onPreExecute()
body: <p>I am new to this site.
  I have an error with my <code>AsyncTask</code> and my android program... this is the first async task that I have written.</p>
  
  <p>The main Class called SocialApp.java</p>
  
  <pre><code>@Override
  public void onCreate(Bundle savedInstanceState){
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
      TextView t = (TextView) this.findViewById(R.id.textView1);       
  
      HTMLParser task = new HTMLParser();
      task.setTextView(t);
      task.execute();        
  }
  </code></pre>
  
  <p>A basic <code>AsyncTask</code></p>
  
  <pre><code>public class HTMLParser extends AsyncTask&lt;Void, Void, Boolean&gt; {
  
      TextView t;
      String title = "error";
  
      public void setTextView(TextView t){
          this.t = t;
      }
  
      @Override
      protected void onPreExecute() {
          t.setText(title);
      }
  
      @Override
      protected Boolean doInBackground(Void ... arg0) {
          t.setText(title);
      }
  
      @Override
      protected void onPostExecute(Boolean result) {
          t.setText(title);
      }
  }
  </code></pre>
  
  <p>Resulting in this</p>
  
  <pre><code>12-15 12:34:11.808: E/AndroidRuntime(590):  at cv.mk.android.utapp.HTMLParser.onPreExecute(HTMLParser.java:24)
  12-15 12:34:11.808: E/AndroidRuntime(590):  at android.os.AsyncTask.executeOnExecutor(AsyncTask.java:561)
  12-15 12:34:11.808: E/AndroidRuntime(590):  at android.os.AsyncTask.execute(AsyncTask.java:511)
  12-15 12:34:11.808: E/AndroidRuntime(590):  at cv.mk.android.utapp.SocialApp.onCreate(SocialApp.java:26)
  12-15 12:34:11.808: E/AndroidRuntime(590):  at android.app.Activity.performCreate(Activity.java:4465)
  12-15 12:34:11.808: E/AndroidRuntime(590):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
  12-15 12:34:11.808: E/AndroidRuntime(590):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1919)
  12-15 12:34:11.808: E/AndroidRuntime(590):  ... 11 more
  12-15 12:34:19.666: D/dalvikvm(609): GC_FOR_ALLOC freed 33K, 3% free 9890K/10179K, paused 215ms
  12-15 12:34:19.677: I/dalvikvm-heap(609): Grow heap (frag case) to 11.363MB for 1700016-byte allocation
  12-15 12:34:19.747: D/dalvikvm(609): GC_CONCURRENT freed &lt;1K, 3% free 11549K/11847K, paused 3ms+12ms
  12-15 12:34:19.967: D/dalvikvm(609): GC_CONCURRENT freed 1K, 2% free 12079K/12231K, paused 2ms+3ms
  12-15 12:34:20.037: D/dalvikvm(609): GC_FOR_ALLOC freed 1K, 2% free 12298K/12487K, paused 24ms
  12-15 12:34:20.277: D/AndroidRuntime(609): Shutting down VM
  12-15 12:34:20.277: W/dalvikvm(609): threadid=1: thread exiting with uncaught exception (group=0x409961f8)
  12-15 12:34:20.277: D/dalvikvm(609): GC_CONCURRENT freed 1K, 1% free 13063K/13191K, paused 3ms+3ms
  12-15 12:34:20.287: E/AndroidRuntime(609): FATAL EXCEPTION: main
  12-15 12:34:20.287: E/AndroidRuntime(609): java.lang.RuntimeException: Unable to start activity ComponentInfo{cv.mk.android.utapp/cv.mk.android.utapp.SocialApp}: java.lang.NullPointerException
  12-15 12:34:20.287: E/AndroidRuntime(609):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1955)
  12-15 12:34:20.287: E/AndroidRuntime(609):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980)
  12-15 12:34:20.287: E/AndroidRuntime(609):  at android.app.ActivityThread.access$600(ActivityThread.java:122)
  12-15 12:34:20.287: E/AndroidRuntime(609):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1146)
  12-15 12:34:20.287: E/AndroidRuntime(609):  at android.os.Handler.dispatchMessage(Handler.java:99)
  12-15 12:34:20.287: E/AndroidRuntime(609):  at android.os.Looper.loop(Looper.java:137)
  12-15 12:34:20.287: E/AndroidRuntime(609):  at android.app.ActivityThread.main(ActivityThread.java:4340)
  12-15 12:34:20.287: E/AndroidRuntime(609):  at java.lang.reflect.Method.invokeNative(Native Method)
  12-15 12:34:20.287: E/AndroidRuntime(609):  at java.lang.reflect.Method.invoke(Method.java:511)
  12-15 12:34:20.287: E/AndroidRuntime(609):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
  12-15 12:34:20.287: E/AndroidRuntime(609):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
  12-15 12:34:20.287: E/AndroidRuntime(609):  at dalvik.system.NativeStart.main(Native Method)
  12-15 12:34:20.287: E/AndroidRuntime(609): Caused by: java.lang.NullPointerException
  12-15 12:34:20.287: E/AndroidRuntime(609):  at cv.mk.android.utapp.HTMLParser.onPreExecute(HTMLParser.java:24)
  12-15 12:34:20.287: E/AndroidRuntime(609):  at android.os.AsyncTask.executeOnExecutor(AsyncTask.java:561)
  12-15 12:34:20.287: E/AndroidRuntime(609):  at android.os.AsyncTask.execute(AsyncTask.java:511)
  12-15 12:34:20.287: E/AndroidRuntime(609):  at cv.mk.android.utapp.SocialApp.onCreate(SocialApp.java:26)
  12-15 12:34:20.287: E/AndroidRuntime(609):  at android.app.Activity.performCreate(Activity.java:4465)
  12-15 12:34:20.287: E/AndroidRuntime(609):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
  12-15 12:34:20.287: E/AndroidRuntime(609):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1919)
  12-15 12:34:20.287: E/AndroidRuntime(609):  ... 11 more
  </code></pre>
  
  <p>I have tried everything and I am really confused as to what is going on here...</p>
  
  <p>Thank you for our time and effort.</p>