當前位置: 首頁>>代碼示例>>Java>>正文


Java WebSettings.setAllowContentAccess方法代碼示例

本文整理匯總了Java中android.webkit.WebSettings.setAllowContentAccess方法的典型用法代碼示例。如果您正苦於以下問題:Java WebSettings.setAllowContentAccess方法的具體用法?Java WebSettings.setAllowContentAccess怎麽用?Java WebSettings.setAllowContentAccess使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.webkit.WebSettings的用法示例。


在下文中一共展示了WebSettings.setAllowContentAccess方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

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

示例2: initData

import android.webkit.WebSettings; //導入方法依賴的package包/類
@SuppressLint("SetJavaScriptEnabled")
@Override
protected void initData() {
    super.initData();
    WebSettings settings = mWebView.getSettings();
    settings.setJavaScriptEnabled(true);
    settings.setDefaultFontSize(10);
    settings.setAllowContentAccess(true);
    mWebView.setWebChromeClient(new WebChromeClient() {
    });
    mEditor = new SourceEditor(mWebView);
    mTextFileName.setText(getArguments().getString("fileName"));
    mPresenter.getCodeDetail();
}
 
開發者ID:hsj-xiaokang,項目名稱:OSchina_resources_android,代碼行數:15,代碼來源:CodeDetailFragment.java

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

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


注:本文中的android.webkit.WebSettings.setAllowContentAccess方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。