android - How to cancel or ignore a Volley request that has already begun? -
this question has answer here:
- android - cancel volley request 4 answers
i know possible cancel volley pending request,what 1 has started?
try this:
requestqueue queue = volley.newrequestqueue(mainactivity.this); string url = "your url"; stringrequest stringrequest = new stringrequest(request.method.get, url, new response.listener<string>() { @override public void onresponse(string response) { toast.maketext(mainactivity.this, "response is: "+ response.substring(0,5), toast.length_short).show(); } }, new response.errorlistener() { @override public void onerrorresponse(volleyerror error) { toast.maketext(mainactivity.this, "that didn't work!", toast.length_short).show(); } }); stringrequest.setretrypolicy(new defaultretrypolicy(0, defaultretrypolicy.default_max_retries, defaultretrypolicy.default_backoff_mult)); queue.add(stringrequest); queue.cancelall(stringrequest);
Comments
Post a Comment