Volley Timeout Error

Android-Volley: TimeOutError when trying to connect from a real device

Add below code in your volley request before request.add(string) to change timeout duration.

request.setRetryPolicy(new DefaultRetryPolicy(
5000,
DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));

android volley TimeoutError

I hope this will work for you.

While accessing localhost API from real device your device must be in the same network or LAN.

Make sure that have you added internet permission in the manifest.

Set DefaultRetryPolicy to your request.

 objectRequest.setShouldCache(false);
objectRequest.setRetryPolicy(new DefaultRetryPolicy(30000,
DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));

Add above code before this requestQueue.add(objectRequest); line.



Related Topics



Leave a reply



Submit