当前位置: 首页>>代码示例>>Java>>正文


Java WebSettings.setAppCacheMaxSize方法代码示例

本文整理汇总了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);
    }
}
 
开发者ID:mangoblogger,项目名称:MangoBloggerAndroidApp,代码行数:16,代码来源:WebFragment.java

示例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());
	}


}
 
开发者ID:NewCasino,项目名称:browser,代码行数:43,代码来源:LightningView.java

示例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);
    }
}
 
开发者ID:yale8848,项目名称:CacheWebView,代码行数:50,代码来源:TestWebView.java


注:本文中的android.webkit.WebSettings.setAppCacheMaxSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。