android - How to cancel or ignore a Volley request that has already begun? -


this question has answer here:

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

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -