不管回调函数里面写了什么,只要页面跳转,LeakCanary就会弹出来内存泄漏。
求助大神
回复讨论(解决方案)
贴代码啊,LogActivity!
HttpUtils.loginRequest(MD5Tool.md5(name), MD5Tool.md5(password), new OnResponseListener< String >() {
@Override
public void onStart(int what) {
}
@Override
public void onSucceed(int what, Response< String > response) {
//根据返回的数据进行判断,如果是判断出登录失败那么吐司,否则跳转
//"wrong".equal(response.getString())
if (false) {
ToastUtils.show("用户名或者密码错误");
} else {
String json = response.get();
User user = new Gson().fromJson(json, User.class);
SharedPreferencesTool.saveString(MyApp.getContext(), Constants.ORGCODE, user.getORG_CODE());
SharedPreferencesTool.saveString(MyApp.getContext(), Constants.USERTYPE, user.getUSER_TYPE());
SharedPreferencesTool.saveString(MyApp.getContext(), Constants.USERCODE, user.getUSER_CODE());
SharedPreferencesTool.saveString(MyApp.getContext(), Constants.USERNAME, user.getUSER_NAME());
SharedPreferencesTool.saveString(MyApp.getContext(), Constants.ID, user.getID());
Log.e("JSON", json);
enterHome();
}
}
@Override
public void onFailed(int what, Response< String > response) {
ToastUtils.show("登录失败");
}
@Override
public void onFinish(int what) {
}
});
HttpUtils.loginRequest(MD5Tool.md5(name), MD5Tool.md5(password), new OnResponseListener< String >() { @Override public void onStart(int what) { } @Override public void onSucceed(int what, Response< String > response) { //根据返回的数据进行判断,如果是判断出登录失败那么吐司,否则跳转 //"wrong".equal(response.getString()) if (false) { ToastUtils.show("用户名或者密码错误"); } else { String json = response.get(); User user = new Gson().fromJson(json, User.class); SharedPreferencesTool.saveString(MyApp.getContext(), Constants.ORGCODE, user.getORG_CODE()); SharedPreferencesTool.saveString(MyApp.getContext(), Constants.USERTYPE, user.getUSER_TYPE()); SharedPreferencesTool.saveString(MyApp.getContext(), Constants.USERCODE, user.getUSER_CODE()); SharedPreferencesTool.saveString(MyApp.getContext(), Constants.USERNAME, user.getUSER_NAME()); SharedPreferencesTool.saveString(MyApp.getContext(), Constants.ID, user.getID()); Log.e("JSON", json); enterHome(); } } @Override public void onFailed(int what, Response< String > response) { ToastUtils.show("登录失败"); } @Override public void onFinish(int what) { } });