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)?
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
Post a Comment