android - Call new request only if response of previous request returns from server -
I need to get a status from the server every 5 seconds. I am using it asyncTask.
Use the request for every 5 seconds
myListTimer = new timer (); MyListTimer.schedule {@Override Public Zero Run (run) {runOnUiThread (New Runnabal) {@Override Public Zero Run () {updateMyList ();}}}}}}, 0, 5000);
Update hereMyList method calls AsyncTask and it works fine. But sometimes due to the network issue I could not find any response within 5 seconds, and the timer again requests a new response. So what I want, it will only request if the last return of the server will be returned if the previous request is not answered then it will not request a new response.
boolean received reception = false; MyListTimer = New Timer (); MyListTimer.schedule {@Override Public Zero Run (run) {runOnUiThread (New Runnabal) {@Override Public Zero Run) (If (Received Reports) {updateMyList ();}}})}} } 0, 5000);
Set the receipt receipted
to correct the set code, when the response is received, it is called.
When you're ready for the next request, set it back.
Comments
Post a Comment