Java Code Examples for android.webkit.WebView#clearCache()
The following examples show how to use
android.webkit.WebView#clearCache() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WebViewSignInActivity.java From input-samples with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.login_webview_activity); WebView webView = findViewById(R.id.webview); WebSettings webSettings = webView.getSettings(); webView.setWebViewClient(new WebViewClient()); webSettings.setJavaScriptEnabled(true); String url = getIntent().getStringExtra("url"); if (url == null) { url = "file:///android_res/raw/sample_form.html"; } if (DEBUG) Log.d(TAG, "Clearing WebView data"); webView.clearHistory(); webView.clearFormData(); webView.clearCache(true); Log.i(TAG, "Loading URL " + url); webView.loadUrl(url); }
Example 2
Source File: FullScreenWebViewDialog.java From VideoOS-Android-SDK with GNU General Public License v3.0 | 6 votes |
private void buildSetting(WebView webView) { webView.clearCache(true); webView.clearHistory(); WebSettings webSettings = webView.getSettings(); webSettings.setJavaScriptCanOpenWindowsAutomatically(true); webSettings.setDefaultTextEncodingName("utf-8");// 避免中文乱码 webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NORMAL); webSettings.setJavaScriptEnabled(true); webSettings.setNeedInitialFocus(false); // webSettings.setDatabaseEnabled(true); webSettings.setDomStorageEnabled(true); // webSettings.setBlockNetworkLoads(true); webSettings.setJavaScriptCanOpenWindowsAutomatically(true); webSettings.setRenderPriority(WebSettings.RenderPriority.HIGH);//1、提高渲染的优先级 // webSettings.setBlockNetworkImage(true);//把图片加载放在最后来加载渲染 webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE); webSettings.setSupportZoom(false); }
Example 3
Source File: FullScreenWebViewDialog.java From VideoOS-Android-SDK with GNU General Public License v3.0 | 6 votes |
private void buildSetting(WebView webView) { webView.clearCache(true); webView.clearHistory(); WebSettings webSettings = webView.getSettings(); webSettings.setJavaScriptCanOpenWindowsAutomatically(true); webSettings.setDefaultTextEncodingName("utf-8");// 避免中文乱码 webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NORMAL); webSettings.setJavaScriptEnabled(true); webSettings.setNeedInitialFocus(false); // webSettings.setDatabaseEnabled(true); webSettings.setDomStorageEnabled(true); // webSettings.setBlockNetworkLoads(true); webSettings.setJavaScriptCanOpenWindowsAutomatically(true); webSettings.setRenderPriority(WebSettings.RenderPriority.HIGH);//1、提高渲染的优先级 // webSettings.setBlockNetworkImage(true);//把图片加载放在最后来加载渲染 webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE); webSettings.setSupportZoom(false); }
Example 4
Source File: AgentWebUtils.java From AgentWeb with Apache License 2.0 | 6 votes |
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(); } } }
Example 5
Source File: WebViewSignInActivity.java From android-AutofillFramework with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.login_webview_activity); WebView webView = findViewById(R.id.webview); WebSettings webSettings = webView.getSettings(); webView.setWebViewClient(new WebViewClient()); webSettings.setJavaScriptEnabled(true); String url = getIntent().getStringExtra("url"); if (url == null) { url = "file:///android_res/raw/sample_form.html"; } if (DEBUG) Log.d(TAG, "Clearing WebView data"); webView.clearHistory(); webView.clearFormData(); webView.clearCache(true); Log.i(TAG, "Loading URL " + url); webView.loadUrl(url); }
Example 6
Source File: EntranceActivity.java From GotoBrowser with GNU General Public License v3.0 | 5 votes |
private void clearBrowserCache() { WebView webview = new WebView(getApplicationContext()); webview.clearCache(true); versionTable.clearVersionDatabase(); String cache_dir = getApplicationContext().getFilesDir().getAbsolutePath().concat("/cache/"); clearApplicationCache(getApplicationContext(), getCacheDir()); clearApplicationCache(getApplicationContext(), new File(cache_dir)); }
Example 7
Source File: RuntimeApi.java From quickhybrid-android with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * 清空webview缓存 */ public static void clearCache(final IQuickFragment webLoader, final WebView wv, JSONObject param, final Callback callback) { wv.clearHistory(); wv.clearCache(true); wv.clearFormData(); new Thread(new Runnable() { @Override public void run() { FileUtil.deleteFile(new File(webLoader.getPageControl().getContext().getCacheDir().getAbsolutePath())); webLoader.getPageControl().getContext().deleteDatabase("webview.db"); webLoader.getPageControl().getContext().deleteDatabase("webviewCache.db"); callback.applySuccess(); } }).start(); }
Example 8
Source File: WebViewUtils.java From Dashchan with Apache License 2.0 | 5 votes |
public static void clearAll(WebView webView) { clearCookie(); if (webView != null) { webView.clearCache(true); } WebViewDatabase webViewDatabase = WebViewDatabase.getInstance(MainApplication.getInstance()); webViewDatabase.clearFormData(); webViewDatabase.clearHttpAuthUsernamePassword(); WebStorage.getInstance().deleteAllData(); }
Example 9
Source File: Login.java From Slide with GNU General Public License v3.0 | 4 votes |
@Override public void onCreate(Bundle savedInstance) { overrideSwipeFromAnywhere(); super.onCreate(savedInstance); applyColorTheme(""); try { setContentView(R.layout.activity_login); } catch(Exception e){ finish(); return; } setupAppBar(R.id.toolbar, R.string.title_login, true, true); String[] scopes = { "identity", "modcontributors", "modconfig", "modothers", "modwiki", "creddits", "livemanage", "account", "privatemessages", "modflair", "modlog", "report", "modposts", "modwiki", "read", "vote", "edit", "submit", "subscribe", "save", "wikiread", "flair", "history", "mysubreddits", "wikiedit" }; if (Authentication.reddit == null) { new Authentication(getApplicationContext()); } final OAuthHelper oAuthHelper = Authentication.reddit.getOAuthHelper(); final Credentials credentials = Credentials.installedApp(CLIENT_ID, REDIRECT_URL); String authorizationUrl = oAuthHelper.getAuthorizationUrl(credentials, true, scopes).toExternalForm(); authorizationUrl = authorizationUrl.replace("www.", "i."); authorizationUrl = authorizationUrl.replace("%3A%2F%2Fi", "://www"); Log.v(LogUtil.getTag(), "Auth URL: " + authorizationUrl); final WebView webView = (WebView) findViewById(R.id.web); webView.clearCache(true); webView.clearHistory(); WebSettings webSettings = webView.getSettings(); webSettings.setJavaScriptEnabled(true); webSettings.setDomStorageEnabled(true); webSettings.setDatabaseEnabled(true); webSettings.setMinimumFontSize(1); webSettings.setMinimumLogicalFontSize(1); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) { CookieManager.getInstance().removeAllCookies(null); CookieManager.getInstance().flush(); } else { CookieSyncManager cookieSyncMngr = CookieSyncManager.createInstance(this); cookieSyncMngr.startSync(); CookieManager cookieManager = CookieManager.getInstance(); cookieManager.removeAllCookie(); cookieManager.removeSessionCookie(); cookieSyncMngr.stopSync(); cookieSyncMngr.sync(); } webView.setWebViewClient(new WebViewClient() { @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { LogUtil.v(url); if (url.contains("code=")) { Log.v(LogUtil.getTag(), "WebView URL: " + url); // Authentication code received, prevent HTTP call from being made. webView.stopLoading(); new UserChallengeTask(oAuthHelper, credentials).execute(url); webView.setVisibility(View.GONE); } } }); webView.loadUrl(authorizationUrl); }
Example 10
Source File: PrivacySettingsFragment.java From JumpGo with Mozilla Public License 2.0 | 4 votes |
private void clearCache() { WebView webView = new WebView(mActivity); webView.clearCache(true); webView.destroy(); Utils.showSnackbar(mActivity, R.string.message_cache_cleared); }
Example 11
Source File: WebUtils.java From JumpGo with Mozilla Public License 2.0 | 4 votes |
public static void clearCache(@Nullable WebView view) { if (view == null) return; view.clearCache(true); }
Example 12
Source File: Utils.java From Leisure with GNU Lesser General Public License v3.0 | 4 votes |
public static void clearCache(){ WebView wb = new WebView(mContext); wb.clearCache(true); DatabaseHelper mHelper = DatabaseHelper.instance(mContext); SQLiteDatabase db = mHelper.getWritableDatabase(); db.execSQL(DatabaseHelper.DELETE_TABLE_DATA + DailyTable.NAME); // db.execSQL(DailyTable.CREATE_TABLE); db.execSQL(DatabaseHelper.DELETE_TABLE_DATA + NewsTable.NAME); // db.execSQL(NewsTable.CREATE_TABLE); db.execSQL(DatabaseHelper.DELETE_TABLE_DATA + ReadingTable.NAME); // db.execSQL(ReadingTable.CREATE_TABLE); db.execSQL(DatabaseHelper.DELETE_TABLE_DATA + ScienceTable.NAME); // db.execSQL(ScienceTable.CREATE_TABLE); }
Example 13
Source File: JamOAuthDialog.java From jam-collaboration-sample with Apache License 2.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.auth_dialog); setCancelable(true); webView = (WebView) findViewById(R.id.webview); // Wipe old web cache webView.clearCache(true); webView.clearFormData(); webView.clearHistory(); webView.clearMatches(); webView.clearSslPreferences(); webSettings = webView.getSettings(); webSettings.setJavaScriptEnabled(true); webSettings.setLoadsImagesAutomatically(true); webSettings.setJavaScriptCanOpenWindowsAutomatically(true); webView.setWebViewClient(new WebViewClient() { @Override public void onPageFinished(WebView view, String url) { super.onPageFinished(view, url); Log.d(TAG, "---------------"); Log.d(TAG, "JamAuthConfig.OAUTH_CALLBACK = " + JamAuthConfig.OAUTH_CALLBACK); Log.d(TAG, "url = " + url); Log.d(TAG, "---------------"); if (url.startsWith(JamAuthConfig.OAUTH_CALLBACK)) { Uri uri = Uri.parse(url); String oauthToken = uri.getQueryParameter(JamAuthConfig.KEY_OAUTH_TOKEN); String oauthVerifier = uri.getQueryParameter(JamAuthConfig.KEY_OAUTH_VERIFIER); Log.d(TAG, "oauthToken = " + oauthToken); Log.d(TAG, "oauthVerifier = " + oauthVerifier); if (oauthToken != null && oauthVerifier != null) { oauthListener.onFinishOAuthAccess(oauthToken, oauthVerifier); } JamOAuthDialog.this.dismiss(); } } }); webView.loadUrl(initialUrl); }
Example 14
Source File: SsoWebViewClient.java From Cirrus_depricated with GNU General Public License v2.0 | 4 votes |
@Override public void onPageStarted (WebView view, String url, Bitmap favicon) { Log_OC.d(TAG, "onPageStarted : " + url); view.clearCache(true); super.onPageStarted(view, url, favicon); }
Example 15
Source File: PrivacySettingsFragment.java From Xndroid with GNU General Public License v3.0 | 4 votes |
private void clearCache() { WebView webView = new WebView(mActivity); webView.clearCache(true); webView.destroy(); Utils.showSnackbar(mActivity, R.string.message_cache_cleared); }
Example 16
Source File: WebUtils.java From Xndroid with GNU General Public License v3.0 | 4 votes |
public static void clearCache(@Nullable WebView view) { if (view == null) return; view.clearCache(true); }
Example 17
Source File: AdvancedSettingsActivity.java From alpha-wallet-android with MIT License | 4 votes |
private void onClearBrowserCacheClicked() { WebView webView = new WebView(this); webView.clearCache(true); Toast.makeText(this, getString(R.string.toast_browser_cache_cleared), Toast.LENGTH_SHORT).show(); }