@Override public void onPageStarted(Tab tab, WebView view, Bitmap favicon) { if (LOGD_ENABLED) Log.d(LOGTAG, "onPageStarted()"); if (view != null) { // Clear history of all previously visited pages. When the // user visits a preloaded tab, the only item in the history // list should the currently viewed page. view.clearHistory(); } }
@Override public void onPageFinished(Tab tab) { if (LOGD_ENABLED) Log.d(LOGTAG, "onPageFinished()"); if (tab != null) { final WebView view = tab.getWebView(); if (view != null) { // Clear history of all previously visited pages. When the // user visits a preloaded tab. view.clearHistory(); } } }
@Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); if (id == R.id.action_settings) { return true; } else if (id == R.id.clear) { // mywebView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE); // // 清除cookie // CookieSyncManager.createInstance(this); // CookieSyncManager.getInstance().startSync(); CookieManager.getInstance().removeAllCookie(); // 清除缓存 mywebView.clearCache(true); mywebView.clearHistory(); clearCacheFolder(this.getCacheDir(), System.currentTimeMillis()); // 删除此时之前的缓存. Toast.makeText(this, "缓存和cookie已被删除", Toast.LENGTH_SHORT).show(); toolbuttons.setVisibility(View.VISIBLE); gotoview.setVisibility(View.VISIBLE); urlText.setVisibility(View.VISIBLE); } else if (id == R.id.urlapi) { // urlText.setText("http://qly.wlgj.kp179.com/plugin.php?id=kp_qly:api"); /*if(!urlText.getText().toString().equals("")) mywebView.loadUrl(urlText.getText().toString()); else mywebView.loadUrl(url); */ String urlString = "http://qly.wlgj.kp179.com/plugin.php?id=kp_qly:api"; if (!urlText.getText().toString().trim().equals("") && urlText.getVisibility() == View.VISIBLE) { urlString += urlText.getText().toString(); } ProgressDialog progressDialog = ProgressDialog.show(this, "加载中", "...", true, false); new Webhttp(this, urlString, progressDialog).run(); } return super.onOptionsItemSelected(item); }