android - Delaying a Task and showing progress bar -


i seem going round in circles. have code on galaxy s3 takes few seconds run. drags data database. want add progress bar popup (spinning circle) around give user app doing something. have tried asyntasks elsewhere in app , work fine type main ui not waiting asyntask finish before moving on , new activity called not have data needs , crashes.

is asynctask best way round or there easier way puase main activity, show progress bar , move on once long deley has been completed.

thanks time

update

public class updatedetailsasynctask extends asynctask<void, void, boolean> {         private context context;     private taskcallback callback;      private arraylist<object> object;      private progressdialog progress;       public updatedetailsasynctask (             context pcontext,              arraylist<object> pobject,             taskcallback pcallback) {          context = pcontext;         callback = pcallback;         object = pobject;      }      @override     protected void onpreexecute() {          log.i("asynctask", "onpreexecuted");          progress = new progressdialog(context);         progress.setmessage(context.getresources().getstring(r.string.loading));         progress.show();      }      @override     protected boolean doinbackground(void... params) {          log.i("archery", "asynctask excuted");         log.i("archery scorepad", "building continue round details");          // save data database          return true;      }       protected void onpostexecute(boolean result) {          log.i("asynctask", "onpostexuted");          progress.dismiss();          callback.startnewactivity();      }  } 

task called main activity

new updatedetailsasynctask(this, arraylistofobjects, this).exute(); 

update 2

..

update 3

the code work calls method within util class in calls database class. have log messages showing rows of data saving database. starts correctly , runs through onpostexecute() appears called before database method has completed.

is issue have nested classes within activity , task appears have completed when class below has not?

thanks

you must change next activity in onpostexecute asyntask


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -