Display a progress dialog while computing

final ProgressDialog dialog = ProgressDialog.show(this, "Title", "Message", true);
final Handler handler = new Handler() {
   public void handleMessage(Message msg) {
      dialog.dismiss();
      }
   };
Thread checkUpdate = new Thread() {  
   public void run() {
//
// YOUR LONG CALCULATION (OR OTHER) GOES HERE
//
      handler.sendEmptyMessage(0);
      }
   };
checkUpdate.start();

3 Comments

#
windstorm - September 11, 2009 at 11:38 p.m.

Why it's 10? I thought it should be 9.8, which is gravity value.

#
windstorm - September 11, 2009 at 11:41 p.m.

Sorry, wrong post......

#
mharkus - September 12, 2009 at 3:52 a.m.

You can just use AsyncTask then show ProgressDialog on onPreExecute method then dismiss it on onPostExecute.

Add a Comment