本文整理汇总了Java中com.tencent.smtt.sdk.WebSettings.setAllowFileAccess方法的典型用法代码示例。如果您正苦于以下问题:Java WebSettings.setAllowFileAccess方法的具体用法?Java WebSettings.setAllowFileAccess怎么用?Java WebSettings.setAllowFileAccess使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.tencent.smtt.sdk.WebSettings
的用法示例。
在下文中一共展示了WebSettings.setAllowFileAccess方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initWebViewSettings
import com.tencent.smtt.sdk.WebSettings; //导入方法依赖的package包/类
private void initWebViewSettings() {
WebSettings ws = mWebView.getSettings();
ws.setDefaultTextEncodingName("utf-8");
ws.setJavaScriptEnabled(true);
ws.setPluginsEnabled(true);
ws.setDomStorageEnabled(true);
ws.setRenderPriority(com.tencent.smtt.sdk.WebSettings.RenderPriority.HIGH);
ws.setAllowFileAccess(true);
ws.setAllowContentAccess(true);
ws.setAppCacheEnabled(false);
ws.setCacheMode(com.tencent.smtt.sdk.WebSettings.LOAD_NO_CACHE);
ws.setSaveFormData(true);
ws.setJavaScriptCanOpenWindowsAutomatically(true);
ws.setLoadsImagesAutomatically(true);
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
ws.setAllowFileAccessFromFileURLs(true);
ws.setAllowUniversalAccessFromFileURLs(true);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
mWebView.setWebContentsDebuggingEnabled(true);
}
}
示例2: initWebViewSettings
import com.tencent.smtt.sdk.WebSettings; //导入方法依赖的package包/类
private void initWebViewSettings() {
WebSettings webSetting = this.getSettings();
webSetting.setJavaScriptEnabled(true);
webSetting.setJavaScriptCanOpenWindowsAutomatically(true);
webSetting.setAllowFileAccess(true);
webSetting.setLayoutAlgorithm(LayoutAlgorithm.NARROW_COLUMNS);
webSetting.setSupportZoom(true);
webSetting.setBuiltInZoomControls(true);
webSetting.setUseWideViewPort(true);
webSetting.setSupportMultipleWindows(true);
// webSetting.setLoadWithOverviewMode(true);
webSetting.setAppCacheEnabled(true);
// webSetting.setDatabaseEnabled(true);
webSetting.setDomStorageEnabled(true);
webSetting.setGeolocationEnabled(true);
webSetting.setAppCacheMaxSize(Long.MAX_VALUE);
// webSetting.setPageCacheCapacity(IX5WebSettings.DEFAULT_CACHE_CAPACITY);
webSetting.setPluginState(WebSettings.PluginState.ON_DEMAND);
// webSetting.setRenderPriority(WebSettings.RenderPriority.HIGH);
webSetting.setCacheMode(WebSettings.LOAD_NO_CACHE);
}
示例3: initWebViewSetting
import com.tencent.smtt.sdk.WebSettings; //导入方法依赖的package包/类
/**
* 初始化WebView的setting事件
*/
private void initWebViewSetting() {
WebSettings webSetting = mWebView.getSettings();
webSetting.setAllowFileAccess(true);
webSetting.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
webSetting.setSupportZoom(true);
webSetting.setBuiltInZoomControls(true);
webSetting.setUseWideViewPort(true);
webSetting.setSupportMultipleWindows(false);
// webSetting.setLoadWithOverviewMode(true);
webSetting.setAppCacheEnabled(true);
// webSetting.setDatabaseEnabled(true);
webSetting.setDomStorageEnabled(true);
webSetting.setJavaScriptEnabled(true);
webSetting.setGeolocationEnabled(true);
webSetting.setAppCacheMaxSize(Long.MAX_VALUE);
webSetting.setAppCachePath(this.getDir("appcache", 0).getPath());
webSetting.setDatabasePath(this.getDir("databases", 0).getPath());
webSetting.setGeolocationDatabasePath(this.getDir("geolocation", 0)
.getPath());
// webSetting.setPageCacheCapacity(IX5WebSettings.DEFAULT_CACHE_CAPACITY);
webSetting.setPluginState(WebSettings.PluginState.ON_DEMAND);
CookieSyncManager.createInstance(this);
CookieSyncManager.getInstance().sync();
}
示例4: initWebViewSettings
import com.tencent.smtt.sdk.WebSettings; //导入方法依赖的package包/类
private void initWebViewSettings() {
WebSettings webSetting = this.getSettings();
webSetting.setJavaScriptEnabled(true);
webSetting.setJavaScriptCanOpenWindowsAutomatically(true);
webSetting.setAllowFileAccess(true);
webSetting.setLayoutAlgorithm(LayoutAlgorithm.NARROW_COLUMNS);
webSetting.setSupportZoom(true);
webSetting.setBuiltInZoomControls(true);
webSetting.setUseWideViewPort(true);
webSetting.setSupportMultipleWindows(true);
webSetting.setAppCacheEnabled(true);
webSetting.setDomStorageEnabled(true);
webSetting.setGeolocationEnabled(true);
webSetting.setAppCacheMaxSize(Long.MAX_VALUE);
webSetting.setPluginState(WebSettings.PluginState.ON_DEMAND);
webSetting.setCacheMode(WebSettings.LOAD_NO_CACHE);
}
示例5: initWebViewSetting
import com.tencent.smtt.sdk.WebSettings; //导入方法依赖的package包/类
/**
* init WebView
*/
private void initWebViewSetting() {
WebSettings webSetting = mWebView.getSettings();
webSetting.setAllowFileAccess(true);
webSetting.setLayoutAlgorithm(LayoutAlgorithm.NARROW_COLUMNS);
webSetting.setSupportZoom(true);
webSetting.setBuiltInZoomControls(true);
webSetting.setUseWideViewPort(true);
webSetting.setSupportMultipleWindows(false);
webSetting.setAppCacheEnabled(true);
webSetting.setDomStorageEnabled(true);
webSetting.setJavaScriptEnabled(true);
webSetting.setGeolocationEnabled(true);
webSetting.setAppCacheMaxSize(Long.MAX_VALUE);
webSetting.setAppCachePath(this.getDir("appcache", 0).getPath());
webSetting.setDatabasePath(this.getDir("databases", 0).getPath());
webSetting.setGeolocationDatabasePath(this.getDir("geolocation", 0)
.getPath());
webSetting.setPluginState(WebSettings.PluginState.ON_DEMAND);
long time = System.currentTimeMillis();
if (mIntentUrl == null) {
mWebView.loadUrl(mHomeUrl);
} else {
mWebView.loadUrl(mIntentUrl.toString());
}
// print the time of webView load
TbsLog.d("time-cost", "cost time: " + (System.currentTimeMillis() - time));
// manage Cookie
CookieSyncManager.createInstance(this);
CookieSyncManager.getInstance().sync();
}
示例6: getWebviewAdaption
import com.tencent.smtt.sdk.WebSettings; //导入方法依赖的package包/类
public void getWebviewAdaption(WebView webView)
{
WebSettings webSettings = webView.getSettings();
webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
webSettings.setUseWideViewPort(true);//关键点
//启用地理定位
webSettings.setDomStorageEnabled(true);
webSettings.setDatabaseEnabled((Boolean) SPUtils.get(context, "if_4", true));//数据库
webSettings.setGeolocationEnabled((Boolean) SPUtils.get(context, "if_2", true));//地理
webSettings.setUserAgentString("" + SPUtils.get(context, "if_7", "Mozilla/5.0 (iPhone; U; CPU iPhone OS 5_1_1 like Mac OS X; en-us) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9B206 Safari/7534.48.3 XiaoMi/MiuiBrowser/8.9.4"));//UA
webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
webSettings.setDisplayZoomControls(false);
webSettings.setLoadsImagesAutomatically((Boolean) SPUtils.get(context, "if_5", true));//图片
webSettings.setJavaScriptEnabled((Boolean) SPUtils.get(context, "if_1", true)); // 设置支持javascript脚本
webSettings.setAllowFileAccess(true); // 允许访问文件
webSettings.setBuiltInZoomControls(true); // 设置显示缩放按钮
webSettings.setSupportZoom((Boolean) SPUtils.get(context, "if_3", false)); // 支持缩放
webSettings.setLoadWithOverviewMode(true);
DisplayMetrics metrics = new DisplayMetrics();
//getWindowManager().getDefaultDisplay().getMetrics(metrics);
int mDensity = metrics.densityDpi;
// Log.d("maomao", "densityDpi = " + mDensity);
if (mDensity == 240)
{
webSettings.setDefaultZoom(WebSettings.ZoomDensity.FAR);
}
else if (mDensity == 160)
{
webSettings.setDefaultZoom(WebSettings.ZoomDensity.MEDIUM);
}
else if (mDensity == 120)
{
webSettings.setDefaultZoom(WebSettings.ZoomDensity.CLOSE);
}
else if (mDensity == DisplayMetrics.DENSITY_XHIGH)
{
webSettings.setDefaultZoom(WebSettings.ZoomDensity.FAR);
}
else if (mDensity == DisplayMetrics.DENSITY_TV)
{
webSettings.setDefaultZoom(WebSettings.ZoomDensity.FAR);
}
else
{
webSettings.setDefaultZoom(WebSettings.ZoomDensity.MEDIUM);
}
webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
}
示例7: initData
import com.tencent.smtt.sdk.WebSettings; //导入方法依赖的package包/类
private void initData() {
//启用支持javascript
WebSettings settings = mWebView.getSettings();
settings.setJavaScriptEnabled(true);
settings.setJavaScriptCanOpenWindowsAutomatically(true);
settings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
settings.setDomStorageEnabled(true);
settings.setAllowFileAccess(true);
settings.setLoadWithOverviewMode(true);
// settings.setTextSize(WebSettings.TextSize.LARGEST);//设置字体大小
settings.setTextZoom(100);//设置字体大小
settings.setDefaultTextEncodingName("utf-8");//设置默认编码格式
// //自适应屏幕
settings.setUseWideViewPort(true);
if (mBody != null) {
try {
//由于body的数据进行了URLEncode编码,所以需要我们再进行URLDecoder解码
//否则只能显示图片
mDecode = URLDecoder.decode(mBody, "utf-8");
//发布时间
mDate = DateUtils.dateFromat(mSenddate);
//自定义样式,设置图片显示大小
mHtml = "<html><body>"
+ "<h3>"
+ mTitle
+ "</h3>"
+ "<p>"
+ "作者:" + mWriter
+ "  "
+ "发布时间:" + mDate
+ "  "
+ "来源:" + mSource
+ "</p>"
+ "<style>"
+ "img{width:100%;height:auto;}"//自定义样式,设置图片显示大小
+ "</style>"
+ mDecode
+ "</body></html>";
mWebView.loadDataWithBaseURL(DMGEAME_URL, mHtml, "text/html", "charset=UTF-8", null);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
Log.e("接收数据", mBody);
}
}
示例8: provideWebView
import com.tencent.smtt.sdk.WebSettings; //导入方法依赖的package包/类
@Provides
@ActivityScope
@SuppressLint("SetJavaScriptEnabled")
WebView provideWebView(Activity activity) {
WebView webView = new WebView(activity) {
boolean isTouchTriggered = false;
@Override
protected void onScrollChanged(int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
if (isTouchTriggered) {
mBaseViewWebX5.onScrollChanged(scrollX, scrollY, oldScrollX, oldScrollY);
}
}
@Override
public boolean onInterceptTouchEvent(MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
isTouchTriggered = true;
}
return super.onInterceptTouchEvent(event);
}
};
WebSettings settings = webView.getSettings();
settings.setJavaScriptEnabled(true);
settings.setAllowFileAccess(true);
settings.setDomStorageEnabled(true);
settings.setUseWideViewPort(true);
settings.setLoadWithOverviewMode(true);
settings.setSupportZoom(false);
settings.setBuiltInZoomControls(false);
settings.setDisplayZoomControls(false);
String userAgent = JoyWeb.getUserAgent();
if (TextUtil.isNotEmpty(userAgent)) {
settings.setUserAgentString(settings.getUserAgentString() + " " + userAgent);
}
settings.setAppCacheEnabled(JoyWeb.isAppCacheEnabled());
settings.setAppCachePath(JoyWeb.getAppCachePath());
settings.setAppCacheMaxSize(JoyWeb.getAppCacheMaxSize());
if (mCacheEnable) {
boolean networkEnable = DeviceUtil.isNetworkEnable(activity.getApplicationContext());
settings.setCacheMode(networkEnable ? WebSettings.LOAD_NO_CACHE : WebSettings.LOAD_CACHE_ONLY);
} else {
settings.setCacheMode(WebSettings.LOAD_NO_CACHE);
}
return webView;
}