Android Volley double post when have slow request
Add the following values to your Request object:
request.setRetryPolicy(new DefaultRetryPolicy(
DefaultRetryPolicy.DEFAULT_TIMEOUT_MS * 2,
DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
Here:
request is your object of JsonObjectRequest. Change the value of multiplicator according to the DEFAULT TIMEOUT VALUE in DefaultRetryPolicy class in Volley.
You can also set the first argument to 0, like below:
request.setRetryPolicy(new DefaultRetryPolicy(
0,
DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
Timeout for server request made using Volley only on Android not iOS
As i have tried to get solution of this issue for about two months, I did not get any perfect solution. Though I analyze some facts as below :
- You can upgrade your server's performance
- I have tried making web-service request using
HttpURLConnection
but still getting same issue over there.
So I think this issue is not specific from volley, but you getting this issue then i would suggest to increase server performance with customizing below RetryPolicy
:
int x=2;// retry count
request.setRetryPolicy(new DefaultRetryPolicy(DefaultRetryPolicy.DEFAULT_TIMEOUT_MS * 48,
x, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
Hope it will help.
Suggestions are always welcome :)
Please comment below if you found more proper solution.
Thanks.!
Related Topics
Theme/Style Is Not Applied When Inflater Used with Applicationcontext
How to Call Methods of a Service from Activity
How to Prevent Going Back to the Previous Activity
Android: Test Push Notification Online (Google Cloud Messaging)
How to Start Power Manager of All Android Manufactures to Enable Background and Push Notification
Android Cancel Toast When Exiting the App and When Toast Is Being Shown
Datepicker Shows Wrong Value of Month
How to Change Action Bar Title Color in Code
How to Handle Multiple Countdown Timers in Listview
Rotating a Bitmap Using Jni & Ndk
Libpng Error: Not a Png File Error Showing in Android Studio
How to Keep an Alertdialog Open After Button Onclick Is Fired
How to Use and Style New Alertdialog from Appcompat 22.1 and Above
Hw Accelerated Activity - How to Get Opengl Texture Size Limit
Upload Video to Facebook in Android
Custom Dialog on Android: How to Center Its Title
Work Around Canvas.Clippath() That Is Not Supported in Android Any More