I am using Android Volley lib in my project to execute network requests, all works very well but I have some troubles with the "cancel" feature of this lib. I explain my issue..
I've an activity, where I'm executing the request at OnCreate method, the request is called, no problem. But to be sure that the cancel method works, I wanted to test and try 2 things :
I fire my request and just after cancel it like this :
MySingleton.getMyData("urltocall", getDataListener, requestTag);MySingleton.getRequestQueue().cancelAll(requestTag);
This one works! The cancel is called (I can see it too in the Request class of Volley) :
public void cancel() {
mCanceled = true; // my breakpoint is called here
}
I fire my request and just after call finish() method of my activity and in
onDestroyand/oronStopmethod of the activity, I'm calling the same code :MySingleton.getMyData("urltocall", getDataListener, requestTag);MySingleton.getRequestQueue().cancelAll(requestTag);
But this doesn't work!
The requestTag is not null and well passed to Volley, so I can't understand why the first method works but not the other one... Knowing that my purpose is to cancel request when onDestroy is called..
Thanks for your help