Android AsyncTask - Start Next Activit From onPostExecute - Bad Idea?
I have an activity which performs a bunch of SQLite inserts as its very last act before starting another activity which relies on the just-inserted data.
I have just moved all the db stuff into an AsyncTask...and, yep, you guessed it, the new activity is being called before the previous one开发者_运维问答's inserts have completed.
Now, I'm happy with the speed of my db operations, but, how do I make my app wait for the AsyncTask to finish before starting the next activity?
I was thinkig about starting it fromonPostExecute, but that feels wrong, although I don't know why it would be if it is.
Currently all I intend to do in pre/postExecute is show a default dialog...but, that's obviously also failing because the next activity is starting as soon as the asyncTask is started :)
No need for AsyncTask usage here, or is there just a simple way to say "woah, boy, wait a sec!"? :)
It's OK to launch the other activity on onPostExecute
... in fact, it sounds reasonable in your case.
精彩评论