當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。