android - Volley Timeout Error -
i trying hit rest service using volley.
public class authfunctions { private static final string login_url = "http://10.0.2.2:8080/stewayservices/user-management/users/10"; boolean result; public boolean loginuser(string email,string password){ jsonobjectrequest request = new jsonobjectrequest(request.method.get,login_url,null,new response.listener<jsonobject>() { @override public void onresponse(jsonobject response) { log.d("jsonobject response",response.tostring()); try { jsonobject user = response.getjsonobject("user"); string firstname = user.getstring("firstname"); if (firstname.equals("lokesh")){ result = true; } else{ result = false; } } catch (jsonexception e) { log.d("web service error",e.getmessage()); e.printstacktrace(); } } },new response.errorlistener() { @override public void onerrorresponse(volleyerror volleyerror) { log.d("jsonobject error response",volleyerror.tostring()); } }); request.setretrypolicy(new defaultretrypolicy(500000, defaultretrypolicy.default_max_retries, defaultretrypolicy.default_backoff_mult)); appcontroller.getinstance().addtorequestqueue(request); return result; } }
but giving me volley timeout error. below logcat
d/jsonobject error response﹕ com.android.volley.timeouterror
please let me know know if doing wrong. first question in stackoverflow regarding android.
this worked me:
request.setretrypolicy(new retrypolicy() { @override public int getcurrenttimeout() { return 50000; } @override public int getcurrentretrycount() { return 50000; } @override public void retry(volleyerror error) throws volleyerror { } });
you can change time.
Comments
Post a Comment