I'm guessing it is in your logic.

If the user is viewing a different Activity, then dialog.isShowing()
is false, so when the ASyncTask finishes, it sees that the dialog is
not showing, so doesn't close it.  When the user switches back to the
calling Activity, then they find the dialog still open with no hope of
ever being closed.

I would either close the dialog before opening the new Intent, or
check if it is open on resume, and if so close it.

On Jan 4, 2:18 am, Mystique <[email protected]> wrote:
> Hi,
>
> I am doing some AsyncTask thing and seems to work ok and after that I
> open another intent to display a listview.
> The thing is, if the user press the back key, it return to the caller
> intent showing the progress dialog and seems to be hanging there until
> it crash. What did I do wrong? I already do a dialog.dismiss()
> onPostExecute().
>
> Please help me out.
>
> Many thanks,
> CJ
>
>     private class LongOperation extends AsyncTask<String, Void,
> String> {
>         ProgressDialog dialog;
>
>         @Override
>         protected String doInBackground(String... params) {
>                 // download something from the net and processing it.
>                 // work perfectly
>                 return null;
>         }
>
>         @Override
>         protected void onPostExecute(String result) {
>                 // execution of result of Long time consuming operation
>                 // some processing from the information taken from the
> internet (doInBackground)
>                 if (dialog.isShowing()) {
>                 dialog.dismiss();
>             }
>         }
>
>         /* (non-Javadoc)
>          * @see android.os.AsyncTask#onPreExecute()
>          */
>         @Override
>         protected void onPreExecute() {
>         // Things to be done before execution of long running operation.
> For example showing ProgessDialog
>                 dialog = ProgressDialog.show(Main.this, "",
>                     "Receiving data", true);
>         }
>
>         @Override
>         protected void onProgressUpdate(Void... values) {
>           // Things to be done while execution of long running
> operation is in progress. For example updating ProgessDialog
>          }
>     }

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to