Cancel All Volley Requests Android

前端 未结 9 1308
我在风中等你
我在风中等你 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:48

    Instead of using a tag for cancelAll, make an all-pass RequestFilter.

    mRequestQueue.cancelAll(new RequestQueue.RequestFilter() {
        @Override
            public boolean apply(Request request) {
                return true;
            }
        });
    

    EDIT: This cancels all Requests from all activities/fragments, and doesn't work favorably with the Activity Lifecycle. The best way to manage this is to add a String tag unique to your fragment.

提交回复
热议问题