android.webkit.WebView.clearCache()方法的使用及代码示例

x33g5p2x  于2022-02-02 转载在 其他  
字(6.9k)|赞(0)|评价(0)|浏览(170)

本文整理了Java中android.webkit.WebView.clearCache()方法的一些代码示例,展示了WebView.clearCache()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebView.clearCache()方法的具体详情如下:
包路径:android.webkit.WebView
类名称:WebView
方法名:clearCache

WebView.clearCache介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

WebView vistaWeb = (WebView) findViewById(R.id.webview);
vistaWeb.setWebChromeClient(new MyCustomChromeClient(this));
vistaWeb.setWebViewClient(new MyCustomWebViewClient(this));
vistaWeb.clearCache(true);
vistaWeb.clearHistory();
vistaWeb.getSettings().setJavaScriptEnabled(true);
vistaWeb.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);

代码示例来源:origin: Justson/AgentWeb

static void clearWebViewAllCache(Context context, WebView webView) {
  try {
    AgentWebConfig.removeAllCookies(null);
    webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
    context.deleteDatabase("webviewCache.db");
    context.deleteDatabase("webview.db");
    webView.clearCache(true);
    webView.clearHistory();
    webView.clearFormData();
    clearCacheFolder(new File(AgentWebConfig.getCachePath(context)), 0);
  } catch (Exception ignore) {
    //ignore.printStackTrace();
    if (AgentWebConfig.DEBUG) {
      ignore.printStackTrace();
    }
  }
}

代码示例来源:origin: termux/termux-app

settings.setAppCacheEnabled(false);
setContentView(progressLayout);
mWebView.clearCache(true);

代码示例来源:origin: TeamNewPipe/NewPipe

myWebView.clearCache(true);
myWebView.clearHistory();
android.webkit.CookieManager cookieManager = CookieManager.getInstance();

代码示例来源:origin: robolectric/robolectric

@Test
public void shouldRecordClearCacheWithoutDiskFiles() {
 assertThat(shadowOf(webView).wasClearCacheCalled()).isFalse();
 webView.clearCache(false);
 assertThat(shadowOf(webView).wasClearCacheCalled()).isTrue();
 assertThat(shadowOf(webView).didClearCacheIncludeDiskFiles()).isFalse();
}

代码示例来源:origin: robolectric/robolectric

@Test
public void shouldRecordClearCacheWithDiskFiles() {
 assertThat(shadowOf(webView).wasClearCacheCalled()).isFalse();
 webView.clearCache(true);
 assertThat(shadowOf(webView).wasClearCacheCalled()).isTrue();
 assertThat(shadowOf(webView).didClearCacheIncludeDiskFiles()).isTrue();
}

代码示例来源:origin: wendux/DSBridge-Android

@Override
public void clearCache(boolean includeDiskFiles) {
  super.clearCache(includeDiskFiles);
  CookieManager.getInstance().removeAllCookie();
  Context context = getContext();
  try {
    context.deleteDatabase("webview.db");
    context.deleteDatabase("webviewCache.db");
  } catch (Exception e) {
    e.printStackTrace();
  }
  File appCacheDir = new File(APP_CACHE_DIRNAME);
  File webviewCacheDir = new File(context.getCacheDir()
      .getAbsolutePath() + "/webviewCache");
  if (webviewCacheDir.exists()) {
    deleteFile(webviewCacheDir);
  }
  if (appCacheDir.exists()) {
    deleteFile(appCacheDir);
  }
}

代码示例来源:origin: syncthing/syncthing-android

/**
 * Initialize WebView.
 *
 * Ignore lint javascript warning as js is loaded only from our known, local service.
 */
@Override
@SuppressLint("SetJavaScriptEnabled")
public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_web_gui);
  mLoadingView = findViewById(R.id.loading);
  mConfig = new ConfigXml(this);
  loadCaCert();
  mWebView = findViewById(R.id.webview);
  mWebView.getSettings().setJavaScriptEnabled(true);
  mWebView.getSettings().setDomStorageEnabled(true);
  mWebView.setWebViewClient(mWebViewClient);
  mWebView.clearCache(true);
  // SyncthingService needs to be started from this activity as the user
  // can directly launch this activity from the recent activity switcher.
  Intent serviceIntent = new Intent(this, SyncthingService.class);
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
    startForegroundService(serviceIntent);
  } else {
    startService(serviceIntent);
  }
}

代码示例来源:origin: vic797/prowebview

/**
 * Clear the cache
 * @see WebView#clearCache(boolean)
 */
public void clearCache() {
  super.clearCache(false);
}

代码示例来源:origin: stackoverflow.com

WebView view = (WebView) findViewById(R.id.webview1);
view = (WebView) findViewById(R.id.webview);
view .setWebChromeClient(new InredisChromeClient(this));
view .setWebViewClient(new InredisWebViewClient(this));
view .clearCache(true);
view .clearHistory();
view .getSettings().setJavaScriptEnabled(true);
view .getSettings().setJavaScriptCanOpenWindowsAutomatically(true);

代码示例来源:origin: andforce/iBeebo

@Override
protected void onDestroy() {
  super.onDestroy();
  mWebView.clearCache(true);
}

代码示例来源:origin: stackoverflow.com

WebView myWebView = (WebView) findViewById(R.id.webview);
myWebView.setWebChromeClient(new InredisChromeClient(this));
myWebView.setWebViewClient(new InredisWebViewClient(this));
myWebView.clearCache(true);
myWebView.clearHistory();
myWebView.getSettings().setJavaScriptEnabled(true);
myWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
myWebView.loadUrl("http://demo.com/content.html?font-size=12&fontcolor=blue");

代码示例来源:origin: stackoverflow.com

WebView img = (WebView) findViewById(R.id.webview);
 img.clearView();
 img.clearCache(true);
 img.getSettings().setBuiltInZoomControls(true);
 img.getSettings().setSupportZoom(false);
 img.loadUrl(image);

代码示例来源:origin: stackoverflow.com

WebView webView = (WebView) findViewById(R.id.webview);
webView = (WebView) findViewById(R.id.webview);
webView.clearCache(true);
webView.clearHistory();
     /* Enabling javascript */
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);

代码示例来源:origin: stackoverflow.com

WebView webView=(WebView)v.findViewById(R.id.webView1);
   FGWebViewClient webViewClient=  new FGWebViewClient(context);
   webView.setWebViewClient(webViewClient);
   webView.setWebChromeClient(new WebChromeClient());
   webView.clearCache(true);
   webView.clearHistory();
   webView.getSettings().setJavaScriptEnabled(true);
   webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
   webView.loadUrl((webUrl).toString());

代码示例来源:origin: stackoverflow.com

WebView browser;
     browser.clearFormData();
 browser.clearHistory();
 browser.clearCache(true);
 browser.getSettings().setAppCacheEnabled(true);
 browser.getSettings().setDatabaseEnabled(true);
 browser.getSettings().setDomStorageEnabled(true);
 browser.setWebChromeClient(new WebChromeClient());

代码示例来源:origin: zhao-mingjian/qvod

@Override
  protected void onDestroy() {
    super.onDestroy();
    if (webView != null) {
      webView.clearCache(true);
      webView.destroy();
    }
  }
}

代码示例来源:origin: wzmyyj/ZYMK

public void clearCookie() {
  CookieSyncManager.createInstance(activity);
  CookieManager cookiemanager = CookieManager.getInstance();
  cookiemanager.removeAllCookie();
  CookieSyncManager.getInstance().sync();
  web.setWebChromeClient(null);
  web.setWebViewClient(null);
  web.getSettings().setJavaScriptEnabled(false);
  web.clearCache(true);
}

代码示例来源:origin: CarlLu/MVPframe

public void clear() {
  if (mWebView != null) {
    mRootView.removeView(mWebView);
    mWebView.clearHistory();
    mWebView.clearCache(true);
    mWebView.destroy();
    mWebView = null;
  }
}

代码示例来源:origin: dabutaizha/juzimi

@Override
protected void onDestroy() {
  super.onDestroy();
  mWebView.clearCache(true);
  CookieManager cookieManager = CookieManager.getInstance();
  cookieManager.setAcceptCookie(true);
  cookieManager.removeSessionCookie();
  cookieManager.removeAllCookie();
}

相关文章

WebView类方法