Android onDestroy防止WebView内存泄露的写法

版权声明:本文为赵勇原创文章,注明出处随便转载。 https://blog.csdn.net/YaphetZhao/article/details/79870372
@Override
    protected void onDestroy() {
        if (mWebView != null) {
            mWebView.loadDataWithBaseURL(null, "", "text/html", "utf-8", null);
            mWebView.clearHistory();
            ((ViewGroup) mWebView.getParent()).removeView(mWebView);
            mWebView.destroy();
            mWebView = null;
        }
        super.onDestroy();
    }

猜你喜欢

转载自blog.csdn.net/YaphetZhao/article/details/79870372