开发者

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", "executionexcept开发者_StackOverflow中文版ion : " + 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


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.


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....


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜