Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 892
muoki_D Avatar asked Mar 13 '23 22:03

muoki_D


1 Answers

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));
like image 52
muoki_D Avatar answered Mar 24 '23 14:03

muoki_D