json - Android Volley JsonObjectRequest returns same response every time on mobile data -
i using volley jsonobjectrequest data server.
code snippet:
jsonobjectrequest jsobjrequest = new jsonobjectrequest (request.method.get, url, null, new response.listener<jsonobject>() { @override public void onresponse(jsonobject response) { system.out.println("response: " + response.tostring()); } }, new response.errorlistener() { @override public void onerrorresponse(volleyerror error) { // todo auto-generated method stub } });
but getting same jsonobject response
every time on mobile data connection.
note: it's work on wifi connection.
is facing issue ? solution ?
@bnk request.setshouldcache(false);
worked me. it's issue of volley cache management.
i assume that, when request sent:
it hit cache first , send
onresponse
then when results come through remote server provide
onresponse
if use of default request classes implemented in volley(e.g. stringrequest, jsonrequest, etc.), call setshouldcache(false)
right before adding request object volley requestqueue
request.setshouldcache(false); myqueue.add(request);
you can set expiration policy cache.
Comments
Post a Comment