title: How to use ProgressDialog to show background progress in android
body: <p>to show a background process i used <code>ProgressDialogBox</code>.</p>
  
  <p><strong>My code is as</strong></p>
  
  <pre><code>add_button.setOnClickListener(new OnClickListener() {
  
  
          public void onClick(View viewParam) {
  
  
              progressDialog = ProgressDialog.show(AddTicketActivity.this, "", "Loading...");
  
              new Thread() {
  
              public void run() {
  
              try{
  
              sleep(10000);
  
              } catch (Exception e) {
  
              Log.e("tag", e.getMessage());
  
              }
  
              progressDialog.dismiss();
              }
  
              }.start();
  </code></pre>
  
  <p>Its working fine. But the problem is progess shows for 10000 ms where as i want it to show untill my data is fetched/added. i mean it should be dependent on fetching/adding time.</p>
  
  <p>i thought to do like it</p>
  
  <pre><code>public void onClick(View viewParam) {
  
  progressDialog = ProgressDialog.show(AddTicketActivity.this, "", "Loading...");
  
  Fetching data code here
  
  progressDialog.dismiss();
  }
  </code></pre>
  
  <p>But it dint work, does not show any progress bar.</p>
  
  <p>How can i use it.</p>
  
  <p>Thanks.</p>