1

我有一个侦听器,可以将 volley 的响应传递给发出请求的活动:

public interface MyListener{
void interpretResponseListener(String response);
void interpretErrorListener(VolleyError error);
}

用于进行调用的方法:

public static void myVolleyRequest(int request code,MyListener myListener){
...
...
}

活动代码:

private MyListener myListener = new MyListener(){
@Override
void interpretResponseListener(String response){
//database changes
}
@Override
void interpretErrorListener(VolleyError error){
//database changes
}

};

myVolleyRequest(100,myListener);

我在响应中对数据库进行了更改。Leakcanary 给我以下错误:

GC ROOT com.android.volley.NetworkDispatcher.<Java Local>
* references com.test.restful.Request.mListener
* references com.test.restfulRestful$44.val$myListener (anonymous class implements com.android.volley.Response$Listener)
* references com.test.Activity$8.this$0 (anonymous class implements com.test.restful.Restful$MyListener)
* leaks com.test.Activity instance
4

0 回答 0