I am using asynctask to do lengthy operations such as DB reads. I want to start a new activity and render its contents when all the asynch tasks are done. What would be the best way to achieve this?
I know that onPostExecute is used to update screen. But I dont want to update screen unless all ther ayncTasks are done
Please help
Thanks
Don’t overcomplicate it: just use a counter that gets incremented in every
onPostExecute. If a task finds this counter to be maxed (equal to the number of tasks you spawned), it can run the update code.Note that you don’t need locking around this counter, since
onPostExecuteruns in the UI thread.