I have two Asynchronous tasks each one in a separate class, I can call them in the main thread, simply using:
new RetrieveTask().execute();
new RetrieveTaskImageData().execute();
But I want the first one to finish before starting the second.
This is an example of one of them:
class RetrieveTask extends AsyncTask<String, Void,Void> {
private Exception exception;
protected Void doInBackground(String... urls) {
try {
//Code here
} catch (Exception e) {
this.exception = e;
} finally {
}
return null;
}
protected void onPostExecute() {
//
}
}
How can we achieve this?
EDIT
Can we use new RetrieveTask().execute().getStatus()==..Finished
?
Thank you
This will be achieved automatically because unless you call executeOnExecutor
, all AsyncTask
s run on the same thread, so two of them can not run concurrently.