So you can identify the states of your task
if(myAsyncUploadFilesTaskFF.getStatus() == AsyncTask.Status.PENDING){
}
if(myAsyncUploadFilesTaskFF.getStatus() == AsyncTask.Status.RUNNING){
}
if(myAsyncUploadFilesTaskFF.getStatus() == AsyncTask.Status.FINISHED){
}
- PENDING: Your homework has not started
- RUNNING:
doInBackground
is running
- FINISHED: I finish
As you are printing it takes myAsyncUploadFilesTaskFF.getStatus().toString()
I imagine you could do something like this (Source of the answer of stack over flow in English, but try to explain a little about Handler
)
Handler myHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case 0:
//Termino de ejecutar la tarea
break;
default:
break;
}
}
};
And within the method onPostExecute
(which already ended)
@Override
protected void onPostExecute(Boolean result) {
myHandler.sendEmptyMessage(0);
}
According to the documentation of the Handler
object, there are two utilities for:
There are two main uses for a Handler: (1) to schedule messages and runnables to be executed as some point in the future; and (2) to enqueue an action to be performed on a different thread than your own.
Spanish (sorry if the translation is not very good):
There are two main uses for a Handler (1) To program messages that will be executed at some future time * and (2) To queue an action to be performed on a Thread different from the current one
In summary the use number (2) is in your case, since you are in your main thread, you want to identify when another thread ends other than the main one (your asynchronous task) and execute an action (Print something)