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


Java WebSettings.setAllowFileAccessFromFileURLs方法代码示例

本文整理汇总了Java中android.webkit.WebSettings.setAllowFileAccessFromFileURLs方法的典型用法代码示例。如果您正苦于以下问题:Java WebSettings.setAllowFileAccessFromFileURLs方法的具体用法?Java WebSettings.setAllowFileAccessFromFileURLs怎么用?Java WebSettings.setAllowFileAccessFromFileURLs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.webkit.WebSettings的用法示例。


在下文中一共展示了WebSettings.setAllowFileAccessFromFileURLs方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreate

import android.webkit.WebSettings; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    webView = (WebView) findViewById(R.id.webView);

    WebSettings settings = webView.getSettings();
    settings.setAllowFileAccessFromFileURLs(true);
    settings.setJavaScriptEnabled(true);

    webView.addJavascriptInterface(new JavascriptHandler(this, webView), "JavascriptHandler");

    webView.loadUrl("file:///android_asset/Sample.framer/index.html");
}
 
开发者ID:mirhoseini,项目名称:framer-android-wrapper,代码行数:16,代码来源:MainActivity.java

示例2: initSettings

import android.webkit.WebSettings; //导入方法依赖的package包/类
private void initSettings(){
    WebSettings webSettings = this.getSettings();

    webSettings.setJavaScriptEnabled(true);

    webSettings.setDomStorageEnabled(true);
    webSettings.setAllowFileAccess(true);
    webSettings.setUseWideViewPort(true);

    webSettings.setUseWideViewPort(true);
    webSettings.setLoadWithOverviewMode(true);

    webSettings.setSupportZoom(false);
    webSettings.setBuiltInZoomControls(false);
    webSettings.setDisplayZoomControls(false);

    webSettings.setDefaultTextEncodingName("UTF-8");

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        webSettings.setAllowFileAccessFromFileURLs(true);
        webSettings.setAllowUniversalAccessFromFileURLs(true);
    }
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
        CookieManager cookieManager = CookieManager.getInstance();
        cookieManager.setAcceptThirdPartyCookies(this,true);
    }
    setWebViewDefaultCacheMode();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        webSettings.setMixedContentMode(
                WebSettings.MIXED_CONTENT_COMPATIBILITY_MODE);
    }
    setCachePath();

}
 
开发者ID:yale8848,项目名称:CacheWebView,代码行数:35,代码来源:CacheWebView.java

示例3: createWebView

import android.webkit.WebSettings; //导入方法依赖的package包/类
@SuppressLint("SetJavaScriptEnabled")
public WebView createWebView(WebView webView) {

    //WebView.setWebContentsDebuggingEnabled(true);
    //不能横向滚动
    webView.setHorizontalScrollBarEnabled(false);
    //不能纵向滚动
    webView.setVerticalScrollBarEnabled(false);
    //允许截图
    webView.setDrawingCacheEnabled(true);
    //屏蔽长按事件
    webView.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            return true;
        }
    });
    //初始化WebSettings
    final WebSettings settings = webView.getSettings();
    settings.setJavaScriptEnabled(true);
    final String ua = settings.getUserAgentString();
    settings.setUserAgentString(ua + "Latte");
    //隐藏缩放控件
    settings.setBuiltInZoomControls(false);
    settings.setDisplayZoomControls(false);
    //禁止缩放
    settings.setSupportZoom(false);
    //文件权限
    settings.setAllowFileAccess(true);
    settings.setAllowFileAccessFromFileURLs(true);
    settings.setAllowUniversalAccessFromFileURLs(true);
    settings.setAllowContentAccess(true);
    //缓存相关
    settings.setAppCacheEnabled(true);
    settings.setDomStorageEnabled(true);
    settings.setDatabaseEnabled(true);
    settings.setCacheMode(WebSettings.LOAD_DEFAULT);

    return webView;
}
 
开发者ID:remerber,项目名称:FastEc,代码行数:41,代码来源:WebViewInitializer.java

示例4: initEvent

import android.webkit.WebSettings; //导入方法依赖的package包/类
private void initEvent() {
    rl_back.setOnClickListener(this);
    rl_option.setOnClickListener(this);
    WebSettings settings = mWebView.getSettings();
    //支持javascript
    settings.setJavaScriptEnabled(true);
    mWebView.addJavascriptInterface(new JsToJava(), "app");
    //设置支持缩放
    settings.setSupportZoom(true);//支持缩放
    settings.setBuiltInZoomControls(true);//设置隐藏缩放按钮
    settings.setDisplayZoomControls(false);//隐藏原生的缩放按钮

    //设置自适应屏幕
    settings.setUseWideViewPort(true);
    settings.setLoadWithOverviewMode(true);

    //屏幕自适应网页  解决低分辨率可能会显示异常的问题
    settings.setDefaultZoom(WebSettings.ZoomDensity.FAR);
    settings.setRenderPriority(WebSettings.RenderPriority.HIGH);
    //自适应屏幕
    settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
    //设置缓存机制
    //settings.setAppCacheEnabled(true);
    settings.setCacheMode(LOAD_NO_CACHE);

    //运行webview通过URI获取安卓文件
    settings.setAllowFileAccess(true);
    settings.setAllowFileAccessFromFileURLs(true);
    settings.setAllowUniversalAccessFromFileURLs(true);

    //支持自动加载图片
    settings.setLoadsImagesAutomatically(true);

    mWebView.setWebViewClient(new MyWebViewClient());
    mWebView.setWebChromeClient(new MyWebChromeClient());
    mWebView.setOnLongClickListener(this);
    mWebView.loadUrl(URL);
}
 
开发者ID:JunGeges,项目名称:AliZhiBoHao,代码行数:39,代码来源:WebActivity.java

示例5: init

import android.webkit.WebSettings; //导入方法依赖的package包/类
private void init(Context context) {
    mPlayer = new WebPlayer(this);

    setBackgroundColor(Color.BLACK);

    enableJavascript();

    WebSettings webSettings = getSettings();
    webSettings.setAllowContentAccess(true);
    webSettings.setAllowFileAccess(true);
    webSettings.setLoadsImagesAutomatically(true);
    webSettings.setDomStorageEnabled(true);
    webSettings.setAppCacheEnabled(true);
    webSettings.setDatabaseEnabled(true);
    webSettings.setDatabasePath(context.getDir("database", Context.MODE_PRIVATE).getPath());

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        webSettings.setAllowFileAccessFromFileURLs(true);
        webSettings.setAllowUniversalAccessFromFileURLs(true);
    }
    
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) {
        webSettings.setRenderPriority(WebSettings.RenderPriority.HIGH);
    }

    setWebChromeClient(new ChromeClient());
    setWebViewClient(new ViewClient());
}
 
开发者ID:AltimitSystems,项目名称:mv-android-client,代码行数:29,代码来源:WebPlayerView.java

示例6: initMap

import android.webkit.WebSettings; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@SuppressLint("SetJavaScriptEnabled")
void initMap(final WebSettings webSettings, final OnMapReadyCallback callback, final String key, MapView mapView) {
    mMapView = mapView;
    IBingMapReadyCallback iBingMapReadyCallback = new IBingMapReadyCallback() {
        @Override
        public void onMapReady() {
            callback.onMapReady(BingMap.this);
        }
    };

    IBingMapScriptLoadCallback iBingMapScriptLoadCallback = new IBingMapScriptLoadCallback() {
        @Override
        public void onScriptLoadSuccess() {
            JsCommandService.getInstance().loadMapScenario(key);
        }
    };

    JsCommandService.getInstance().observe(iBingMapReadyCallback, IBingMapReadyCallback.class);
    JsCommandService.getInstance().observe(iBingMapScriptLoadCallback, IBingMapScriptLoadCallback.class);
    if (webSettings != null) {
        webSettings.setJavaScriptEnabled(true);
        webSettings.setAllowFileAccessFromFileURLs(true);
        webSettings.setAllowUniversalAccessFromFileURLs(true);
    }
    JsCommandService.getInstance().loadAssets();
}
 
开发者ID:bravecheng,项目名称:BingMapDemo,代码行数:28,代码来源:BingMap.java

示例7: 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

示例8: 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

示例9: initSettings

import android.webkit.WebSettings; //导入方法依赖的package包/类
private void initSettings(){
    WebSettings webSettings = mWebView.getSettings();

    webSettings.setJavaScriptEnabled(true);

    webSettings.setDomStorageEnabled(true);
    webSettings.setAllowFileAccess(true);
    webSettings.setUseWideViewPort(true);

    webSettings.setUseWideViewPort(true);
    webSettings.setLoadWithOverviewMode(true);

    webSettings.setSupportZoom(false);
    webSettings.setBuiltInZoomControls(false);
    webSettings.setDisplayZoomControls(false);

    webSettings.setDefaultTextEncodingName("UTF-8");

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        webSettings.setAllowFileAccessFromFileURLs(true);
        webSettings.setAllowUniversalAccessFromFileURLs(true);
    }
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
        CookieManager cookieManager = CookieManager.getInstance();
        cookieManager.setAcceptThirdPartyCookies(mWebView,true);
    }
   if (NetworkUtils.isConnected(mWebView.getContext()) ){
        webSettings.setCacheMode(WebSettings.LOAD_DEFAULT);
    } else {
        webSettings.setCacheMode(
                WebSettings.LOAD_CACHE_ELSE_NETWORK);
    }



    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        webSettings.setMixedContentMode(
                WebSettings.MIXED_CONTENT_COMPATIBILITY_MODE);
    }
    setCachePath();

}
 
开发者ID:yale8848,项目名称:CacheWebView,代码行数:43,代码来源:Main2Activity.java


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