ProgressDialog in Android

This is the good way to use progress dialog in Android
Code coloring by 
Source from


//example code on using Progress Dialog in Android
private class YourAsyncTask extends AsyncTask<Void, Void, Void> {

   ProgressDialog dialog = new ProgressDialog(IncidentFormActivity.this);

    protected void onPreExecute() {
        //set message of the dialog
        //show dialog;

   protected Void doInBackground(Void... args) {
    // do background work here
    return null;

   protected void onPostExecute(Void result) {
     // do UI work here
     if(dialog != null && dialog.isShowing()){


No comments:

Post a Comment

Popular Posts