title: How to stop ProgressDialog and Thread?
body: <p>i am new to android development. i created an sample map application, once we enter the location code, ProgressDialog will be shown while the location is loading. Once the location is displayed, ProgressDialog is to be dismissed, but it keeps on going even after the location is displayed in background.
  Below is my code.</p>
  
  <pre><code>Thread background = new Thread(new Runnable() {
  
                      public void run() {
  
                          try {
                              Thread.sleep(5000);
                              if(webLocation == true){
                                  progressDialog.dismiss();
  
  
                              }
                                } catch (InterruptedException e) {
  
                                e.printStackTrace();
  
                      }
  
                  }
                  });
              background.start();
  
              }
  </code></pre>
  
  <p>can anyone give me a solution for stopping the ProgressDialog, once the location is shown. i can't get an idea for this solution, if anyone has some ideas or solution, it will be helpful for me. </p>