Cancel All Volley Requests Android

前端 未结 9 1307
我在风中等你
我在风中等你 2020-12-05 14:23

At the moment i´m using mRequestQueue.cancelAll(getActivity()) at on stop method in a fragment but apparently when i move the phone from landscape to portrait it is still re

9条回答
  •  情话喂你
    2020-12-05 14:57

    I know this answer comes in late, but in case anyone else is having this problem:

    In my implementation the Tag was being set (and overwritten) at the point where the request was added to the queue.

    So despite that I was cancelling the request with my Tag, the tag on the request queue was not the same (as it was previously overwritten) and it was not cancelled.

    Logging the requests running and printing out the tags, led me to the solution:

    mRequestQueue.cancelAll(new RequestQueue.RequestFilter() {
        @Override
            public boolean apply(Request request) {
            Log.d("DEBUG","request running: "+request.getTag().toString());
                return true;
            }
    });
    

提交回复
热议问题