本文整理匯總了Java中android.webkit.WebSettings.setAppCacheMaxSize方法的典型用法代碼示例。如果您正苦於以下問題:Java WebSettings.setAppCacheMaxSize方法的具體用法?Java WebSettings.setAppCacheMaxSize怎麽用?Java WebSettings.setAppCacheMaxSize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.webkit.WebSettings
的用法示例。
在下文中一共展示了WebSettings.setAppCacheMaxSize方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: enableCache
import android.webkit.WebSettings; //導入方法依賴的package包/類
/**
* Function to enable caching
*/
private void enableCache() {
WebSettings webSettings = mWebView.getSettings();
webSettings.setAppCacheMaxSize(5 * 1024 * 1024); // 5MB
webSettings.setAppCachePath(getContext().getCacheDir().getAbsolutePath());
webSettings.setAllowFileAccess(true);
webSettings.setAppCacheEnabled(true);
webSettings.setCacheMode(WebSettings.LOAD_DEFAULT); // load online by default
if (!AppUtils.isNetworkConnected(getContext())) { // loading offline
webSettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
}
}
示例2: initializeSettings
import android.webkit.WebSettings; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
@SuppressLint({ "SetJavaScriptEnabled", "NewApi" })
public void initializeSettings(WebSettings settings, Context context) {
//setPageCacheCapacity2(settings);
if (API < 18) {
settings.setAppCacheMaxSize(Long.MAX_VALUE);
}
if (API < 17) {
settings.setEnableSmoothTransition(true);
}
if (API > 16) {
settings.setMediaPlaybackRequiresUserGesture(true);
}
if (API >= Build.VERSION_CODES.LOLLIPOP && !mBrowserController.isIncognito()) {
settings.setMixedContentMode(WebSettings.MIXED_CONTENT_COMPATIBILITY_MODE);
} else if (API >= Build.VERSION_CODES.LOLLIPOP) {
// We're in Incognito mode, reject
settings.setMixedContentMode(WebSettings.MIXED_CONTENT_NEVER_ALLOW);
}
settings.setDomStorageEnabled(true);
settings.setAppCacheEnabled(true);
settings.setCacheMode(WebSettings.LOAD_DEFAULT);
settings.setDatabaseEnabled(true);
settings.setSupportZoom(true);
settings.setBuiltInZoomControls(true);
settings.setDisplayZoomControls(false);
settings.setAllowContentAccess(true);
settings.setAllowFileAccess(true);
settings.setDefaultTextEncodingName("utf-8");
if (API > 16) {
settings.setAllowFileAccessFromFileURLs(false);
settings.setAllowUniversalAccessFromFileURLs(false);
}
settings.setAppCachePath(context.getDir("appcache", 0).getPath());
settings.setGeolocationDatabasePath(context.getDir("geolocation", 0).getPath());
if (API < Build.VERSION_CODES.KITKAT) {
settings.setDatabasePath(context.getDir("databases", 0).getPath());
}
}
示例3: initSettings
import android.webkit.WebSettings; //導入方法依賴的package包/類
private void initSettings() {
WebSettings webSettings = mDXHWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
if (Build.VERSION.SDK_INT >= 16) {
webSettings.setAllowFileAccessFromFileURLs(true);
}
webSettings.setDomStorageEnabled(true);
webSettings.setAllowFileAccess(true);
webSettings.setUseWideViewPort(true);
webSettings.setLoadWithOverviewMode(true);
if (NetworkUtils.isConnected(mContext) ){
webSettings.setCacheMode(WebSettings.LOAD_DEFAULT);
} else {
webSettings.setCacheMode(
WebSettings.LOAD_CACHE_ELSE_NETWORK);
}
webSettings.setDatabaseEnabled(true);
webSettings.setAppCacheMaxSize(1024 * 1024 * 8);
webSettings.setAppCacheEnabled(true);
//File fDatabase = new File(mContext.getCacheDir().getAbsolutePath(),"webview_db");
//webSettings.setDatabasePath(fDatabase.getAbsolutePath());
File fAppCache = new File(mContext.getCacheDir().getAbsolutePath(),"webview_cache");
webSettings.setAppCachePath(fAppCache.getAbsolutePath());
webSettings.setBuiltInZoomControls(true);// api-3
webSettings.setPluginState(WebSettings.PluginState.ON);
webSettings.setRenderPriority(WebSettings.RenderPriority.HIGH);
if (Build.VERSION.SDK_INT >= 11) {
webSettings.setDisplayZoomControls(false);// api-11
}
//http://wiki.jikexueyuan.com/project/chrome-devtools/remote-debugging-on-android.html
if (Build.VERSION.SDK_INT >= 19) {//for chrome debug
WebView.setWebContentsDebuggingEnabled(true);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
webSettings.setMixedContentMode(
WebSettings.MIXED_CONTENT_COMPATIBILITY_MODE);
}
}