muoki_D
muoki_D

Reputation: 409

volley request being hit twice to the server

I have experienced a problem with volley where a request sometimes gets hit twice to the server and as a result, this pretty much messes up my code logic. Is there a way I can limit the number of requests to 1? I have tried doing what is explained here but the problem still occurs sometimes

Upvotes: 1

Views: 999

Answers (1)

muoki_D
muoki_D

Reputation: 409

I just thought I could answer this, i figured out the solution. Google finally adopted the volley library and this is the official repo to add to your dependencies compile 'com.android.volley:volley:1.0.0'

Also, add this to your string request. Set the DEFAULT_TIMEOUT_MS multiple times, like in my case, i set it to 5

stringRequest.setRetryPolicy(new DefaultRetryPolicy(DefaultRetryPolicy.DEFAULT_TIMEOUT_MS * 5, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));

Upvotes: 3

Related Questions