@Override public void run() { if (webView != null) { webView.destroy(); } } }, ViewConfiguration.getZoomControlsTimeout() + 1000L);
/** * Called when the fragment is no longer in use. Destroys the internal state of the WebView. */ @Override public void onDestroy() { if (mWebView != null) { mWebView.destroy(); mWebView = null; } super.onDestroy(); }
/** * Called when the fragment is no longer in use. Destroys * the internal state of the WebView. */ @Override public void onDestroy() { if (mWebView != null) { mWebView.destroy(); mWebView=null; } super.onDestroy(); }
@Override protected void onDestroy() { super.onDestroy(); if (wvWebView != null) { wvWebView.destroy(); wvWebView = null; } wvWebView = null; }
@Override protected void onDestroy() { mWebView.destroy(); mHandler.removeCallbacksAndMessages(null); super.onDestroy(); } }
@Override protected void onDestroy() { if (wvWebView != null) { wvWebView.destroy(); wvWebView = null; } super.onDestroy(); }
@Override protected void onDestroy() { super.onDestroy(); if (null != mWebView) { mWebView.destroy(); mWebView = null; } }
@Override public void onDestroyView() { super.onDestroyView(); if (null != mWebView) { mWebView.destroy(); mWebView = null; } }
private void destroyWebView(WebView webView) { if (webView != null) { webView.stopLoading(); webView.setWebChromeClient(null); webView.setWebViewClient(null); webView.destroy(); } }
@Override public void onDestroy() { super.onDestroy(); if (webView != null) { webView.destroy(); } }
@Override public void onDestroy() { super.onDestroy(); mWebView.destroy(); }
public class TestActivity extends Activity { private FrameLayout mWebContainer; private WebView mWebView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.your_layout); mWebContainer = (FrameLayout) findViewById(R.id.web_container); mWebView = new WebView(getApplicationContext()); mWebContainer.addView(mWebView); } @Override protected void onDestroy() { super.onDestroy(); mWebContainer.removeAllViews(); mWebView.destroy(); } }
/** * Called to instantiate the view. Creates and returns the WebView. */ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (mWebView != null) { mWebView.destroy(); } mWebView = new WebView(getContext()); mIsWebViewAvailable = true; return mWebView; }
@Override protected void onDestroy() { if(webView!=null) { webView.removeAllViews(); webView.destroy(); } super.onDestroy(); }
/** * Called to instantiate the view. Creates and returns the * WebView. */ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (mWebView != null) { mWebView.destroy(); } mWebView=new WebView(getContext()); mIsWebViewAvailable=true; return mWebView; }
static final void clearWebView(WebView m) { if (m == null) { return; } if (Looper.myLooper() != Looper.getMainLooper()) { return; } m.loadUrl("about:blank"); m.stopLoading(); if (m.getHandler() != null) { m.getHandler().removeCallbacksAndMessages(null); } m.removeAllViews(); ViewGroup mViewGroup = null; if ((mViewGroup = ((ViewGroup) m.getParent())) != null) { mViewGroup.removeView(m); } m.setWebChromeClient(null); m.setWebViewClient(null); m.setTag(null); m.clearHistory(); m.destroy(); m = null; }
@Override public void destroy() { setVisibility(View.GONE); if (mJsCallJavas != null) { mJsCallJavas.clear(); } if (mInjectJavaScripts != null) { mInjectJavaScripts.clear(); } removeAllViewsInLayout(); fixedStillAttached(); releaseConfigCallback(); if (mIsInited) { resetAccessibilityEnabled(); // LogUtils.i(TAG, "destroy web"); super.destroy(); } }
@Override protected void onDestroy() { if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.LOLLIPOP) { getWindow().getSharedElementReturnTransition().removeListener(zhihuReturnHomeListener); } //webview内存泄露 if (wvZhihu != null) { ((ViewGroup) wvZhihu.getParent()).removeView(wvZhihu); wvZhihu.destroy(); wvZhihu = null; } mIZhihuStoryPresenter.unsubscrible(); super.onDestroy(); }
@Override protected void onDestroy() { super.onDestroy(); webView.destroy(); // Put cookies back to okhttp cookie store CookieManager cookieManager = CookieManager.getInstance(); String cookiesString = cookieManager.getCookie(url); if (cookiesString != null && !cookiesString.isEmpty()) { EhCookieStore store = EhApplication.getEhCookieStore(this); HttpUrl eUrl = HttpUrl.parse(EhUrl.HOST_E); HttpUrl exUrl = HttpUrl.parse(EhUrl.HOST_EX); // The cookies saved in the uconfig page should be shared between e and ex for (String header : cookiesString.split(";")) { Cookie eCookie = Cookie.parse(eUrl, header); if (eCookie != null) { store.addCookie(longLive(eCookie)); } Cookie exCookie = Cookie.parse(exUrl, header); if (exCookie != null) { store.addCookie(longLive(exCookie)); } } } }
@Test public void shouldRecordDestroy() { assertThat(shadowOf(webView).wasDestroyCalled()).isFalse(); webView.destroy(); assertThat(shadowOf(webView).wasDestroyCalled()).isTrue(); }