app/src/main/java/fish/pondof/s/MainActivity.java
public void clearWebViewResource() {
        if (webview!= null) {
            Log.d(StaticValue.LOG_TAG,"Clear webview's resources");
            webview.removeAllViews();
            // in android 5.1(sdk:21) we should invoke this to avoid memory leak
            // see (https://coolpers.github.io/webview/memory/leak/2015/07/16/
            // android-5.1-webview-memory-leak.html)
            ((ViewGroup) webview.getParent()).removeView(webview);
            webview.setTag(null);
            webview.clearHistory();
            webview.destroy();
            webview = null;
        }
    }
/**
     * Description: release the memory of web view, otherwise it's resource will not be recycle.
     * Created by Michael Lee on 7/18/16 20:38
     */
release the memory of web view, otherwise it's resource will not be recycle.
release the memory of web view otherwise it ' s resource will not be recycle .
public void clearWebViewResource() {
        if (webview!= null) {
            Log.d(StaticValue.LOG_TAG,"Clear webview's resources");
            webview.removeAllViews();
            ((ViewGroup) webview.getParent()).removeView(webview);
            webview.setTag(null);
            webview.clearHistory();
            webview.destroy();
            webview = null;
        }
    }
public void clearWebViewResource ( ) { if ( webview != null ) { Log . d ( StaticValue . LOG_TAG , "Clear webview's resources" ) ; webview . removeAllViews ( ) ; ( ( ViewGroup ) webview . getParent ( ) ) . removeView ( webview ) ; webview . setTag ( null ) ; webview . clearHistory ( ) ; webview . destroy ( ) ; webview = null ; } }
Description: release the memory of web view, otherwise it's resource will not be recycle.
Description : release the memory of web view otherwise it ' s resource will not be recycle .
// in android 5.1(sdk:21) we should invoke this to avoid memory leak // see (https://coolpers.github.io/webview/memory/leak/2015/07/16/ // android-5.1-webview-memory-leak.html)