1
I have a class Main that performs a method receberSolicitantes() with a task in background. While it is executed, it updates a progressBar.
Everything is working perfectly with the method as follows:
public void receberSolicitantes() {
JsonReceber receber = new JsonReceber(this, "solicitantes", this.progressBar);
receber.execute();
}
But when I put the line receber.get() (as shown below) to fetch the return, the method onProgressUpdate (asynchronous class JsonReceber) is only executed at the end of doInBackground, and thus, the progressBar doesn’t work.
Added receber.get():
public void receberSolicitantes() {
JsonReceber receber = new JsonReceber(this, "solicitantes", this.pb);
receber.execute();
try {
receber.get();
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}
}
How do I find the return of background execution ?
It would be the same way I do with progressBar leading on the call
JsonReceber receber = new JsonReceber(this, "solicitantes", this.progressBar) ?