title: Android - Starting a thread crashes app
body: <p>I've got a few activities.  In the main activity I have a login screen, when the user presses the login button, a thread is started to show a progress dialog until the user has been authenticated.  At this point i load the next activity which has several fields for the user to input data.</p>
  
  <p>Here the user inputs some data and presses a button to process it.  The data is passed to a new activity where the data is actually processed and displayed.  This is where i create the new thread and where it's crashing when i call thread.start(); and I have no idea why this is happening.</p>
  
  <p>Both activities are implementing Runnable.</p>
  
  <p>I'm using the same code below to create and call thread.start() in the button press of the first activity and the onCreate method of the last one: </p>
  
  <pre><code>pd = ProgressDialog.show(search_results.this, "", "Searching...", true, false);
      Thread thread = new Thread(this);
      thread.start();
  </code></pre>
  
  <p>I'm using the same code below as well to handle the threads for both as well.</p>
  
  <pre><code>public void run() {
      handler.sendEmptyMessage(0);
  }
  private Handler handler = new Handler() {
      @Override
      public void handleMessage(Message msg) {            
              pd.dismiss();               
      }
  };
  </code></pre>
  
  <p>Am I missing something?  I don't really understand why it's crashing.</p>