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


Java WebSettings.setAllowUniversalAccessFromFileURLs方法代码示例

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


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

示例1: setUpWebView

import android.webkit.WebSettings; //导入方法依赖的package包/类
@SuppressLint("SetJavaScriptEnabled")
private void setUpWebView(WebView view) {
    view.addJavascriptInterface(mScriptBridge, "rhino");
    WebSettings webSettings = view.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webSettings.setAllowUniversalAccessFromFileURLs(true);
}
 
开发者ID:feifadaima,项目名称:https-github.com-hyb1996-NoRootScriptDroid,代码行数:8,代码来源:InjectableWebClient.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: onViewCreated

import android.webkit.WebSettings; //导入方法依赖的package包/类
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    WebView webView = (WebView) view.findViewById(R.id.webView);
    WebSettings settings = webView.getSettings();
    settings.setJavaScriptEnabled(true);
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) {
        settings.setAllowUniversalAccessFromFileURLs(true);
    }
    settings.setBuiltInZoomControls(true);
    //webView.setWebChromeClient(new WebChromeClient());
    webView.setWebViewClient(new WebViewClient());
    webView.loadUrl(GOOGLE_DRIVE_LINK2 + WEB_PATH_TO_PDF);
}
 
开发者ID:WorldBank-Transport,项目名称:RoadLab-Pro,代码行数:15,代码来源:PdfViewFragment.java

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

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

示例10: enableUniversalAccess

import android.webkit.WebSettings; //导入方法依赖的package包/类
static void enableUniversalAccess(WebSettings settings) {
    settings.setAllowUniversalAccessFromFileURLs(true);
}
 
开发者ID:aabognah,项目名称:LoRaWAN-Smart-Parking,代码行数:4,代码来源:CordovaWebView.java


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