I send a request to the server but it takes a long time to receive the result, I noticed that the AsyncTask that sends the location to the server every 1 second is in the way.
I noticed this after I changed it to 3 seconds, where I sent a new request that took from 1 to 3 seconds.
The code where AsyncTask is used is below:
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
//Atualizar GeoLocalização
localizacao.setUsuario(motoqueiro.getId());
localizacao.setLatitude(location.getLatitude());
localizacao.setLongitude(location.getLongitude());
new GeoUpdateAsynctask().execute(localizacao);
handler.postDelayed(this, APP_REFRESH_TIME * 1000);
}
}, APP_REFRESH_TIME * 1000);
}
I would like to suggest some other method that I can use in this case, since I use several AsyncTask in parallel.