i want to fetch some data from a URL and the server is very slow...
So whenever i use volley to get the data, I get TimeOurError
,
Is there anyway i can handle for how long volley should try to get the data as the server is slow...It takes little time
and i also want to run this request constantly to check data, I plan to use Timer for it...Is it okay to use Timer for continuously checking data?
Here is my volley request for now...It works for other URL's
public void checkData() {
StringRequest stringRequest = new StringRequest(Request.Method.POST, URL,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
Log.i("Response",response);
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.i("Response",error.toString());
}
}){
@Override
protected Map<String, String> getParams() throws AuthFailureError {
Map<String,String> map = new HashMap<String,String>();
map.put("deviceID","none");
return map;
}
};
RequestQueue requestQueue = Volley.newRequestQueue(this);
requestQueue.add(stringRequest);
}
and i need to call this functions continuously( inside app)
UPDATE
I used
tringRequest.setRetryPolicy(new DefaultRetryPolicy(
30000,
DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
and it worked, Now I want to make this request continuously in my app...What is the best approach for that?