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.

see answer more details


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -