android - ProgressDialog never shows up when the task right after is an upload (or other processor intensitve process) -


i'm trying display progressdialog indicate user should wait while uploads in background, however, device (galaxy tab) freezes time upload happens , when comes out of stupor goes next thing (having never displayed progressdialog.

when eliminate upload, dialog appears expected. i'm guessing async issue? dialog simple never gets time slice , time it's been dismissed?

pd = progressdialog.show(getapplicationcontext(),"", "sending image ...", true); uploadimage(); //if comment out line, dialog shows, otherwise not. pd.dismiss(); 

is there way block on progressdialog line until renders? or overlooking stupid (and obvious)?

this similar doing.

long story short use asynctask , call uploadimage() inside doinbackground()

 new asynctask<void, void, void>() {          @override         protected void onpreexecute()         {              pd = progressdialog.show(getapplicationcontext(),"", "sending image ...", true);             log.d(tag, "onpreexecute()");         }          @override         protected void doinbackground(void... params)         {             log.d(tag, "doinbackground() -- here upload");             uploadimages();             return null;         }          @override         protected void onpostexecute(void res)         {             log.d(tag, "onpostexecute()");             pd.dismiss();         }     }.execute(); 

Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -