Monday, 15 June 2015

ProgressDialog not dismissing in onPostExecute() android -



ProgressDialog not dismissing in onPostExecute() android -

i have read solutions same question, did not seem find answer. have progressdialog showing in onpreexecute() of asynctask. not dismiss after doinbackground() finished.

here code:-

main.java

case r.id.action_refresh: new refreshitems().execute(); homecoming true; private class refreshitems extends asynctask<void, void, void> { progressdialog refdialog ; fragment fragment = null; list<news> updatedlist; @override protected void onpostexecute(void result) { // todo auto-generated method stub super.onpostexecute(result); if(refdialog!=null && refdialog.isshowing() && refdialog.isindeterminate()) refdialog.dismiss(); } @override protected void onpreexecute() { // todo auto-generated method stub super.onpreexecute(); refdialog = progressdialog.show(home.this, "", "please wait", true, false); } @override protected void doinbackground(void... params) { // todo auto-generated method stub seek { updatedlist = new getlist().execute(items).get(); fragment = new homefragment(sphosturl,encodedaccountname,deviceauthkey,usersname,avatarurl, fullname,getapplicationcontext(),updatedlist); } grab (interruptedexception e) { // todo auto-generated grab block e.printstacktrace(); } grab (executionexception e) { // todo auto-generated grab block e.printstacktrace(); } homecoming null; } // todo auto-generated method stub }

problem:

refdialog.isindeterminate()

you not measuring homecoming false, not dismissing dialog.

solution:

remove in if statement

if(refdialog!=null && refdialog.isshowing())

also remove this:

super.onpostexecute(result);

you dont need default onpostexecute;

edit:

problem 2:

progressdialog.show(home.this, "", "please wait", true, false);

you set cancelable false mean can not cancel upon dismissing.

change showing of dialog this:

refdialog = progressdialog.show(home.this, "", "please wait")

android progressdialog

No comments:

Post a Comment