Jonny
Jonny

Reputation: 35

Android ProgressDialog not showing

In the following code:

Log.v("dialog", "dialogshow");
ProgressDialog dialog = ProgressDialog.show(UBActivity.this, "", "Loading calendar, please wait...",     true);

boolean res;
try {
    res = new Utils().new DownloadCalendarTask().execute().get();
} catch (InterruptedException e) {
    Log.v("downloadcalendar", "interruptedexecution : " + e.getLocalizedMessage());
    res = false;
} catch (ExecutionException e) {
    Log.v("downloadcalendar", "executionexception : " + e.getLocalizedMessage());
    res = false;
}
Log.v("dialog", "dialogdismiss");
dialog.dismiss();

According to logcat there is an 8 second difference between dialogshow and dialogdismiss showing in the log, yet I don't see the ProgressDialog appear at all. The background action is happening not in the UI thread (it's an AsyncTask) so that shouldn't be the problem?

Many thanks!u

Upvotes: 0

Views: 3581

Answers (3)

shkschneider
shkschneider

Reputation: 18253

If you don't see the ProgressDialog, I think it is because of the Context.

Are you sure UBActivity.this is the right Activity?

I had the exact same problem and fixed it by passing the Context to my ASync class constructor.

Upvotes: 0

Samir Mangroliya
Samir Mangroliya

Reputation: 40426

In AsyncTask There Are Three Method....

OnpreExecute you start your progressDialog and then Your task is running in do in background.. After completing the do in background Methods the onPostExecute method is calling itself and then Dismiss your dialog onPostExecute method....

Upvotes: 1

Finn Larsen
Finn Larsen

Reputation: 2199

Try putting your ProgressDialog inside your AsyncTask: Create the ProgressDialog and show it in PreExecute. Do your downloading in the Background and dismiss the ProgressDialog in PostExecute.

Upvotes: 3

Related Questions