title: Android - progress dialog does not close
body: <p>I have a ListActivity class, and when any item on the list is clicked, a new activity is displayed. The new activity takes time to load, so i would like the users to know that there is something happening (in the form of a progress dialog)</p>
  
  <p>So, in order to do this, i implemented Runnable in my class like this - </p>
  
  <pre><code>public class ProtocolListActivity extends ListActivity implements Runnable {
  private ProgressDialog progDialog;
  ....
  protected void onListItemClick(ListView l, View v, int position, long id) {
                      progDialog.show(this, "Showing Data..", "please wait", true, false);
  
      Thread thread = new Thread(this);
      thread.start();
  }
  ....
  public void run() {
       // some code to start new activity based on which item the user has clicked.
  }
  </code></pre>
  
  <p>Initially, when i click, and the new activity is being loaded, the progress dialog works nicely, but when i close the previous activity (to get back to this list) the progress dialog is still running. I want the progress dialog to show up only for the time the new activity is being started.</p>
  
  <p>Can someone please guide me on how to do this correctly. </p>