MVP内存泄露

在presenter写

  //防止内存泄露
    public void onDeth(){
        if (urlView!=null){
            urlView=null;
        }
        if (urlModel!=null){
            urlModel=null;
        }
    }

在mainactivity调用

 @Override
    protected void onDestroy() {
        super.onDestroy();
       
        if (uriPresenter!=null){
            uriPresenter.onDeth();
            uriPresenter=null;
        }
    }

猜你喜欢

转载自blog.csdn.net/qq_43413728/article/details/85716764