You can query the status of an AsyncTask
using getStatus()
, to check if a given task has ended and then start the other task, but it would imply to check constantly for the status of wach task and this is not a good idea.
You can also, as you say, start the following task on the onPostExecute
of each other, but seeing the names of your tasks I think that you are also using the tasks separately, so it would imply some kind of flag to control whether the tasks should be chained or not.
Maybe the better approach could be to create a new AsyncTask
that executes al the work done by each of tour tasks (could need some refactoring to do the work in methods to avoid duplicating your code).
From the documentation:
AsyncTask is designed to be a helper class around Thread and Handler
and does not constitute a generic threading framework.
So, maybe in your case AsyncTask
is not the right tool to do the job and you should think about using plain Threads as @ZygoteInit proposes.