Skip to content Skip to sidebar Skip to footer

Pressing Button And Continuing To Next Intent, Progressdialog

I want to show a ProgressDialog when my app is uploading an image. As uploading an image can take quite a while. Now I have 2 Asynctasks, one for uploading an Image to the server,

Solution 1:

Do not dismiss the dialog in UploadImageTask

protected void onPostExecute(Integer result) {
       // dialog.dismiss();
        new MyAsyncTask().execute(_mail);
    }

But dismiss the same in MyAsyncTask

 protected void onPostExecute(Integer result) {
  if (dialog.isShowing()) 
    {
           dialog.dismiss();
    }
 }

Solution 2:

what you can do is pass your progress dialog of step4 in MyAsyncTask when you execute MyAsyncTask using new MyAsyncTask().execute(_mail)

MyAsyncTask

privateclassMyAsyncTaskextendsAsyncTask<Mail, Integer, Double> {

    privateProgressDialogprogress=null// create constructor to get ProgressDialog passed from onPostExecute of your UploadImageTaskpublicMyAsyncTask(ProgressDialog progress)
        {
        this.progress = progress;
        }

    // now continue `this.progress` here and dismiss `this.progress` on `onPostExecute` method here
    } 

onPostExecute of your UploadImageTask

protectedvoidonPostExecute(Integer result)
 {
       // remove dialog.dismiss(); // dont dismiss dialog here.MyAsyncTaskasync = newMyAsyncTask(dialog) // pass your current dialogasync.execute(_mail);
 }

sorry for any typo . hope this will help

Post a Comment for "Pressing Button And Continuing To Next Intent, Progressdialog"