本文整理汇总了Java中android.webkit.WebSettings.setSupportMultipleWindows方法的典型用法代码示例。如果您正苦于以下问题:Java WebSettings.setSupportMultipleWindows方法的具体用法?Java WebSettings.setSupportMultipleWindows怎么用?Java WebSettings.setSupportMultipleWindows使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.webkit.WebSettings
的用法示例。
在下文中一共展示了WebSettings.setSupportMultipleWindows方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import android.webkit.WebSettings; //导入方法依赖的package包/类
@SuppressLint("SetJavaScriptEnabled")
private void init(Context context) {
// 顶部显示的进度条
mProgressBar = new ProgressBar(context, null, android.R.attr.progressBarStyleHorizontal);
mProgressBar.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, 7, 0, 0));
Drawable drawable = context.getResources().getDrawable(R.drawable.layer_web_progress_bar);
mProgressBar.setProgressDrawable(drawable);
addView(mProgressBar);
WebSettings webSettings = this.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setSupportZoom(true); // 是能放大缩小
webSettings.setUseWideViewPort(true);
webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
webSettings.setLoadWithOverviewMode(true);
webSettings.setBuiltInZoomControls(true);
webSettings.setDisplayZoomControls(false);//隐藏
webSettings.setDomStorageEnabled(true);
webSettings.setSupportMultipleWindows(true);
//webSettings.setUseWideViewPort(true);
this.setWebViewClient(mWebViewClientBase);
this.setWebChromeClient(mWebChromeClientBase);
setDownloadListener(new DownloadListener());
this.onResume();
}
示例2: init
import android.webkit.WebSettings; //导入方法依赖的package包/类
private void init() {
final WebSettings setting = getSettings();
setting.setJavaScriptEnabled(true);
setting.setSupportZoom(false);
setting.setSupportMultipleWindows(true);
setting.setSupportZoom(false);
setting.setBuiltInZoomControls(false);
setting.setSupportMultipleWindows(true);
setting.setJavaScriptCanOpenWindowsAutomatically(true);
setting.setDomStorageEnabled(true);
setting.setNeedInitialFocus(false);
setting.setGeolocationEnabled(true);
setting.setAllowFileAccess(true);
setFocusable(true);
setFocusableInTouchMode(true);
}
示例3: initView
import android.webkit.WebSettings; //导入方法依赖的package包/类
@Override
public void initView() {
mIbToolbarMore.setVisibility(View.VISIBLE);
//设置webView
WebSettings settings = mWebView.getSettings();
settings.setRenderPriority(WebSettings.RenderPriority.HIGH);
settings.setSupportMultipleWindows(true);
settings.setJavaScriptEnabled(true);
settings.setSavePassword(false);
settings.setJavaScriptCanOpenWindowsAutomatically(true);
settings.setMinimumFontSize(settings.getMinimumLogicalFontSize() + 8);
settings.setAllowFileAccess(false);
settings.setTextSize(WebSettings.TextSize.NORMAL);
mWebView.setVerticalScrollbarOverlay(true);
mWebView.setWebViewClient(new MyWebViewClient());
mWebView.loadUrl(mUrl);
setToolbarTitle(TextUtils.isEmpty(mTitle) ? mWebView.getTitle() : mTitle);
}
示例4: onCreate
import android.webkit.WebSettings; //导入方法依赖的package包/类
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
try {
Bundle extras = getIntent().getExtras();
if (extras == null) {
finish();
return;
}
try {
String string = extras.getString("url");
if (k.a(string)) {
Method method;
super.requestWindowFeature(1);
this.c = new Handler(getMainLooper());
View linearLayout = new LinearLayout(getApplicationContext());
LayoutParams layoutParams = new LinearLayout.LayoutParams(-1, -1);
linearLayout.setOrientation(1);
setContentView(linearLayout, layoutParams);
this.a = new WebView(getApplicationContext());
layoutParams.weight = 1.0f;
this.a.setVisibility(0);
linearLayout.addView(this.a, layoutParams);
WebSettings settings = this.a.getSettings();
settings.setUserAgentString(settings.getUserAgentString() + k.c(getApplicationContext()));
settings.setRenderPriority(RenderPriority.HIGH);
settings.setSupportMultipleWindows(true);
settings.setJavaScriptEnabled(true);
settings.setSavePassword(false);
settings.setJavaScriptCanOpenWindowsAutomatically(true);
settings.setMinimumFontSize(settings.getMinimumFontSize() + 8);
settings.setAllowFileAccess(false);
settings.setTextSize(TextSize.NORMAL);
this.a.setVerticalScrollbarOverlay(true);
this.a.setWebViewClient(new a());
this.a.setDownloadListener(new a(this));
this.a.loadUrl(string);
if (VERSION.SDK_INT >= 7) {
try {
method = this.a.getSettings().getClass().getMethod("setDomStorageEnabled", new Class[]{Boolean.TYPE});
if (method != null) {
method.invoke(this.a.getSettings(), new Object[]{Boolean.valueOf(true)});
}
} catch (Exception e) {
}
}
try {
method = this.a.getClass().getMethod("removeJavascriptInterface", new Class[0]);
if (method != null) {
method.invoke(this.a, new Object[]{"searchBoxJavaBridge_"});
return;
}
return;
} catch (Exception e2) {
return;
}
}
finish();
} catch (Exception e3) {
finish();
}
} catch (Exception e4) {
finish();
}
}
示例5: onCreate
import android.webkit.WebSettings; //导入方法依赖的package包/类
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
try {
Bundle extras = getIntent().getExtras();
if (extras == null) {
finish();
return;
}
try {
String string = extras.getString("url");
if (k.a(string)) {
Method method;
super.requestWindowFeature(1);
this.c = new Handler(getMainLooper());
Object string2 = extras.getString("cookie");
if (!TextUtils.isEmpty(string2)) {
CookieSyncManager.createInstance(getApplicationContext()).sync();
CookieManager.getInstance().setCookie(string, string2);
CookieSyncManager.getInstance().sync();
}
View linearLayout = new LinearLayout(getApplicationContext());
LayoutParams layoutParams = new LinearLayout.LayoutParams(-1, -1);
linearLayout.setOrientation(1);
setContentView(linearLayout, layoutParams);
this.a = new WebView(getApplicationContext());
layoutParams.weight = 1.0f;
this.a.setVisibility(0);
linearLayout.addView(this.a, layoutParams);
WebSettings settings = this.a.getSettings();
settings.setUserAgentString(settings.getUserAgentString() + k.c(getApplicationContext()));
settings.setRenderPriority(RenderPriority.HIGH);
settings.setSupportMultipleWindows(true);
settings.setJavaScriptEnabled(true);
settings.setSavePassword(false);
settings.setJavaScriptCanOpenWindowsAutomatically(true);
settings.setMinimumFontSize(settings.getMinimumFontSize() + 8);
settings.setAllowFileAccess(false);
settings.setTextSize(TextSize.NORMAL);
this.a.setVerticalScrollbarOverlay(true);
this.a.setWebViewClient(new a());
this.a.loadUrl(string);
if (VERSION.SDK_INT >= 7) {
try {
method = this.a.getSettings().getClass().getMethod("setDomStorageEnabled", new Class[]{Boolean.TYPE});
if (method != null) {
method.invoke(this.a.getSettings(), new Object[]{Boolean.valueOf(true)});
}
} catch (Exception e) {
}
}
try {
method = this.a.getClass().getMethod("removeJavascriptInterface", new Class[0]);
if (method != null) {
method.invoke(this.a, new Object[]{"searchBoxJavaBridge_"});
return;
}
return;
} catch (Exception e2) {
return;
}
}
finish();
} catch (Exception e3) {
finish();
}
} catch (Exception e4) {
finish();
}
}
示例6: onCreate
import android.webkit.WebSettings; //导入方法依赖的package包/类
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
try {
Bundle extras = getIntent().getExtras();
if (extras == null) {
finish();
return;
}
try {
this.d = extras.getString(b);
String string = extras.getString("params");
if (k.a(string)) {
Method method;
super.requestWindowFeature(1);
this.f = new Handler(getMainLooper());
View linearLayout = new LinearLayout(getApplicationContext());
LayoutParams layoutParams = new LinearLayout.LayoutParams(-1, -1);
linearLayout.setOrientation(1);
setContentView(linearLayout, layoutParams);
this.c = new WebView(getApplicationContext());
layoutParams.weight = 1.0f;
this.c.setVisibility(0);
linearLayout.addView(this.c, layoutParams);
WebSettings settings = this.c.getSettings();
settings.setUserAgentString(settings.getUserAgentString() + k.c(getApplicationContext()));
settings.setRenderPriority(RenderPriority.HIGH);
settings.setSupportMultipleWindows(true);
settings.setJavaScriptEnabled(true);
settings.setSavePassword(false);
settings.setJavaScriptCanOpenWindowsAutomatically(true);
settings.setMinimumFontSize(settings.getMinimumFontSize() + 8);
settings.setAllowFileAccess(false);
settings.setTextSize(TextSize.NORMAL);
this.c.setVerticalScrollbarOverlay(true);
this.c.setWebViewClient(new b());
this.c.setWebChromeClient(new a());
this.c.setDownloadListener(new a(this));
this.c.loadUrl(string);
if (VERSION.SDK_INT >= 7) {
try {
method = this.c.getSettings().getClass().getMethod("setDomStorageEnabled", new Class[]{Boolean.TYPE});
if (method != null) {
method.invoke(this.c.getSettings(), new Object[]{Boolean.valueOf(true)});
}
} catch (Exception e) {
}
}
try {
method = this.c.getClass().getMethod("removeJavascriptInterface", new Class[0]);
if (method != null) {
method.invoke(this.c, new Object[]{"searchBoxJavaBridge_"});
return;
}
return;
} catch (Exception e2) {
return;
}
}
finish();
} catch (Exception e3) {
finish();
}
} catch (Exception e4) {
finish();
}
}
示例7: initWebView
import android.webkit.WebSettings; //导入方法依赖的package包/类
private void initWebView() {
WebSettings ws = mWebView.getSettings();
// 网页内容的宽度是否可大于WebView控件的宽度
ws.setLoadWithOverviewMode(false);
// 保存表单数据
ws.setSaveFormData(true);
// 是否应该支持使用其屏幕缩放控件和手势缩放
ws.setSupportZoom(true);
ws.setBuiltInZoomControls(true);
ws.setDisplayZoomControls(false);
// 启动应用缓存
ws.setAppCacheEnabled(true);
// 设置缓存模式
ws.setCacheMode(WebSettings.LOAD_DEFAULT);
// setDefaultZoom api19被弃用
// 设置此属性,可任意比例缩放。
ws.setUseWideViewPort(true);
// 缩放比例 1
mWebView.setInitialScale(1);
// 告诉WebView启用JavaScript执行。默认的是false。
ws.setJavaScriptEnabled(true);
// 页面加载好以后,再放开图片
ws.setBlockNetworkImage(false);
// 使用localStorage则必须打开
ws.setDomStorageEnabled(true);
// 排版适应屏幕
ws.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
// WebView是否支持多个窗口。
ws.setSupportMultipleWindows(true);
// webview从5.0开始默认不允许混合模式,https中不能加载http资源,需要设置开启。
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
ws.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
}
/** 设置字体默认缩放大小(改变网页字体大小,setTextSize api14被弃用)*/
ws.setTextZoom(100);
mWebView.setWebViewClient(new MyWebViewClient());
mWebView.setWebChromeClient(webChromeClient = new MyWebChromeClient());
mWebView.loadUrl(url);
}
示例8: initWebSettings
import android.webkit.WebSettings; //导入方法依赖的package包/类
private void initWebSettings() {
WebSettings settings = mWebView.getSettings();
//支持获取手势焦点
mWebView.requestFocusFromTouch();
//支持JS
settings.setJavaScriptEnabled(true);
//支持插件
settings.setPluginState(WebSettings.PluginState.ON);
//设置适应屏幕
settings.setUseWideViewPort(true);
settings.setLoadWithOverviewMode(true);
//支持缩放
settings.setSupportZoom(false);
//隐藏原生的缩放控件
settings.setDisplayZoomControls(false);
//支持内容重新布局
settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
settings.supportMultipleWindows();
settings.setSupportMultipleWindows(true);
//设置缓存模式
settings.setDomStorageEnabled(true);
settings.setDatabaseEnabled(true);
settings.setCacheMode(WebSettings.LOAD_DEFAULT);
settings.setAppCacheEnabled(true);
settings.setAppCachePath(mWebView.getContext().getCacheDir().getAbsolutePath());
//设置可访问文件
settings.setAllowFileAccess(true);
//当webview调用requestFocus时为webview设置节点
settings.setNeedInitialFocus(true);
//支持自动加载图片
if (Build.VERSION.SDK_INT >= 19) {
settings.setLoadsImagesAutomatically(true);
} else {
settings.setLoadsImagesAutomatically(false);
}
settings.setNeedInitialFocus(true);
//设置编码格式
settings.setDefaultTextEncodingName("UTF-8");
}
示例9: onCreate
import android.webkit.WebSettings; //导入方法依赖的package包/类
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
try {
Bundle extras = getIntent().getExtras();
if (extras == null) {
finish();
return;
}
try {
String string = extras.getString("url");
if (i.b(string)) {
Method method;
super.requestWindowFeature(1);
this.c = new Handler(getMainLooper());
View linearLayout = new LinearLayout(getApplicationContext());
LayoutParams layoutParams = new LinearLayout.LayoutParams(-1, -1);
linearLayout.setOrientation(1);
setContentView(linearLayout, layoutParams);
this.a = new WebView(getApplicationContext());
layoutParams.weight = 1.0f;
this.a.setVisibility(0);
linearLayout.addView(this.a, layoutParams);
WebSettings settings = this.a.getSettings();
settings.setUserAgentString(settings.getUserAgentString() + i.c(getApplicationContext()));
settings.setRenderPriority(RenderPriority.HIGH);
settings.setSupportMultipleWindows(true);
settings.setJavaScriptEnabled(true);
settings.setSavePassword(false);
settings.setJavaScriptCanOpenWindowsAutomatically(true);
settings.setMinimumFontSize(settings.getMinimumFontSize() + 8);
settings.setAllowFileAccess(false);
settings.setTextSize(TextSize.NORMAL);
this.a.setVerticalScrollbarOverlay(true);
this.a.setWebViewClient(new a());
this.a.setDownloadListener(new b(this));
this.a.loadUrl(string);
if (VERSION.SDK_INT >= 7) {
try {
method = this.a.getSettings().getClass().getMethod("setDomStorageEnabled", new Class[]{Boolean.TYPE});
if (method != null) {
method.invoke(this.a.getSettings(), new Object[]{Boolean.valueOf(true)});
}
} catch (Exception e) {
}
}
try {
method = this.a.getClass().getMethod("removeJavascriptInterface", new Class[0]);
if (method != null) {
method.invoke(this.a, new Object[]{"searchBoxJavaBridge_"});
method.invoke(this.a, new Object[]{"accessibility"});
method.invoke(this.a, new Object[]{"accessibilityTraversal"});
return;
}
return;
} catch (Exception e2) {
return;
}
}
finish();
} catch (Exception e3) {
finish();
}
} catch (Exception e4) {
finish();
}
}
示例10: onCreate
import android.webkit.WebSettings; //导入方法依赖的package包/类
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
try {
Bundle extras = getIntent().getExtras();
if (extras == null) {
finish();
return;
}
try {
String string = extras.getString("url");
if (i.b(string)) {
Method method;
super.requestWindowFeature(1);
this.c = new Handler(getMainLooper());
Object string2 = extras.getString("cookie");
if (!TextUtils.isEmpty(string2)) {
CookieSyncManager.createInstance(getApplicationContext()).sync();
CookieManager.getInstance().setCookie(string, string2);
CookieSyncManager.getInstance().sync();
}
View linearLayout = new LinearLayout(getApplicationContext());
LayoutParams layoutParams = new LinearLayout.LayoutParams(-1, -1);
linearLayout.setOrientation(1);
setContentView(linearLayout, layoutParams);
this.a = new WebView(getApplicationContext());
layoutParams.weight = 1.0f;
this.a.setVisibility(0);
linearLayout.addView(this.a, layoutParams);
WebSettings settings = this.a.getSettings();
settings.setUserAgentString(settings.getUserAgentString() + i.c(getApplicationContext()));
settings.setRenderPriority(RenderPriority.HIGH);
settings.setSupportMultipleWindows(true);
settings.setJavaScriptEnabled(true);
settings.setSavePassword(false);
settings.setJavaScriptCanOpenWindowsAutomatically(true);
settings.setMinimumFontSize(settings.getMinimumFontSize() + 8);
settings.setAllowFileAccess(false);
settings.setTextSize(TextSize.NORMAL);
this.a.setVerticalScrollbarOverlay(true);
this.a.setWebViewClient(new a());
this.a.loadUrl(string);
if (VERSION.SDK_INT >= 7) {
try {
method = this.a.getSettings().getClass().getMethod("setDomStorageEnabled", new Class[]{Boolean.TYPE});
if (method != null) {
method.invoke(this.a.getSettings(), new Object[]{Boolean.valueOf(true)});
}
} catch (Exception e) {
}
}
try {
method = this.a.getClass().getMethod("removeJavascriptInterface", new Class[0]);
if (method != null) {
method.invoke(this.a, new Object[]{"searchBoxJavaBridge_"});
method.invoke(this.a, new Object[]{"accessibility"});
method.invoke(this.a, new Object[]{"accessibilityTraversal"});
return;
}
return;
} catch (Exception e2) {
return;
}
}
finish();
} catch (Exception e3) {
finish();
}
} catch (Exception e4) {
finish();
}
}
示例11: onCreate
import android.webkit.WebSettings; //导入方法依赖的package包/类
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
try {
Bundle extras = getIntent().getExtras();
if (extras == null) {
finish();
return;
}
try {
this.d = extras.getString(b);
String string = extras.getString("params");
if (i.b(string)) {
Method method;
super.requestWindowFeature(1);
this.f = new Handler(getMainLooper());
View linearLayout = new LinearLayout(getApplicationContext());
LayoutParams layoutParams = new LinearLayout.LayoutParams(-1, -1);
linearLayout.setOrientation(1);
setContentView(linearLayout, layoutParams);
this.c = new WebView(getApplicationContext());
layoutParams.weight = 1.0f;
this.c.setVisibility(0);
linearLayout.addView(this.c, layoutParams);
WebSettings settings = this.c.getSettings();
settings.setUserAgentString(settings.getUserAgentString() + i.c(getApplicationContext()));
settings.setRenderPriority(RenderPriority.HIGH);
settings.setSupportMultipleWindows(true);
settings.setJavaScriptEnabled(true);
settings.setSavePassword(false);
settings.setJavaScriptCanOpenWindowsAutomatically(true);
settings.setMinimumFontSize(settings.getMinimumFontSize() + 8);
settings.setAllowFileAccess(false);
settings.setTextSize(TextSize.NORMAL);
this.c.setVerticalScrollbarOverlay(true);
this.c.setWebViewClient(new b());
this.c.setWebChromeClient(new a());
this.c.setDownloadListener(new a(this));
this.c.loadUrl(string);
if (VERSION.SDK_INT >= 7) {
try {
method = this.c.getSettings().getClass().getMethod("setDomStorageEnabled", new Class[]{Boolean.TYPE});
if (method != null) {
method.invoke(this.c.getSettings(), new Object[]{Boolean.valueOf(true)});
}
} catch (Exception e) {
}
}
try {
method = this.c.getClass().getMethod("removeJavascriptInterface", new Class[0]);
if (method != null) {
method.invoke(this.c, new Object[]{"searchBoxJavaBridge_"});
method.invoke(this.c, new Object[]{"accessibility"});
method.invoke(this.c, new Object[]{"accessibilityTraversal"});
return;
}
return;
} catch (Exception e2) {
return;
}
}
finish();
} catch (Exception e3) {
finish();
}
} catch (Exception e4) {
finish();
}
}
示例12: initWebView
import android.webkit.WebSettings; //导入方法依赖的package包/类
private void initWebView() {
mProgressBar.setVisibility(View.VISIBLE);
WebSettings ws = webView.getSettings();
// 网页内容的宽度是否可大于WebView控件的宽度
ws.setLoadWithOverviewMode(false);
// 保存表单数据
ws.setSaveFormData(true);
// 是否应该支持使用其屏幕缩放控件和手势缩放
ws.setSupportZoom(true);
ws.setBuiltInZoomControls(true);
ws.setDisplayZoomControls(false);
// 启动应用缓存
ws.setAppCacheEnabled(true);
// 设置缓存模式
ws.setCacheMode(WebSettings.LOAD_DEFAULT);
// setDefaultZoom api19被弃用
// 设置此属性,可任意比例缩放。
ws.setUseWideViewPort(true);
// 缩放比例 1
webView.setInitialScale(1);
// 告诉WebView启用JavaScript执行。默认的是false。
ws.setJavaScriptEnabled(true);
// 页面加载好以后,再放开图片
ws.setBlockNetworkImage(false);
// 使用localStorage则必须打开
ws.setDomStorageEnabled(true);
// 排版适应屏幕
ws.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
// WebView是否支持多个窗口。
ws.setSupportMultipleWindows(true);
// webview从5.0开始默认不允许混合模式,https中不能加载http资源,需要设置开启。
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
ws.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
}
/** 设置字体默认缩放大小(改变网页字体大小,setTextSize api14被弃用)*/
ws.setTextZoom(100);
mWebChromeClient = new MyWebChromeClient(this);
webView.setWebChromeClient(mWebChromeClient);
// 与js交互
webView.addJavascriptInterface(new ImageClickInterface(this), "injectedObject");
webView.setWebViewClient(new MyWebViewClient(this));
}
示例13: setUpWebViewDefaults
import android.webkit.WebSettings; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void setUpWebViewDefaults(WebView webView) {
WebSettings settings = webView.getSettings();
// 网页内容的宽度是否可大于WebView控件的宽度
settings.setLoadWithOverviewMode(false);
// 保存表单数据
settings.setSaveFormData(true);
// 是否应该支持使用其屏幕缩放控件和手势缩放
settings.setSupportZoom(true);
settings.setBuiltInZoomControls(true);
settings.setDisplayZoomControls(false);
// 启动应用缓存
settings.setAppCacheEnabled(true);
// 设置缓存模式
settings.setCacheMode(WebSettings.LOAD_DEFAULT);
// setDefaultZoom api19被弃用
// 设置此属性,可任意比例缩放。
settings.setUseWideViewPort(true);
// 缩放比例 1
webView.setInitialScale(1);
// 告诉WebView启用JavaScript执行。默认的是false。
settings.setJavaScriptEnabled(true);
// 页面加载好以后,再放开图片
settings.setBlockNetworkImage(false);
// 使用localStorage则必须打开
settings.setDomStorageEnabled(true);
// 排版适应屏幕
settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
// WebView是否支持多个窗口。
settings.setSupportMultipleWindows(true);
// webview从5.0开始默认不允许混合模式,https中不能加载http资源,需要设置开启。
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
settings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
}
/** 设置字体默认缩放大小(改变网页字体大小,setTextSize api14被弃用)*/
settings.setTextZoom(100);
// Enable remote debugging via chrome://inspect
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
WebView.setWebContentsDebuggingEnabled(true);
}
// AppRTC requires third party cookies to work
CookieManager cookieManager = CookieManager.getInstance();
cookieManager.setAcceptThirdPartyCookies(webView, true);
}
示例14: initWebView
import android.webkit.WebSettings; //导入方法依赖的package包/类
@SuppressLint({"SetJavaScriptEnabled", "AddJavascriptInterface"})
private void initWebView() {
//进度条设置可见
mProgressBar.setVisibility(View.VISIBLE);
//获取webView的Setting
WebSettings ws = webView.getSettings();
// 网页内容的宽度是否可大于WebView控件的宽度
ws.setLoadWithOverviewMode(false);
//保存表单数据
ws.setSaveFormData(true);
// 是否支持屏幕手势缩放功能
ws.setSupportZoom(true);
ws.setBuiltInZoomControls(true);
//设置true会在WebView上出现点击放大缩小的按钮,前提是setSupportZoom为true
ws.setDisplayZoomControls(false);
// 启动应用缓存
ws.setAppCacheEnabled(true);
ws.setDatabaseEnabled(true);
// 设置缓存模式
if (CheckNetwork.isNetworkConnected(this)) {
ws.setCacheMode(WebSettings.LOAD_DEFAULT);//网络正常时使用默认缓存策略
} else {
ws.setCacheMode(WebSettings.LOAD_CACHE_ONLY);//网络不可用时只使用缓存
}
// setDefaultZoom api19被弃用
// 设置此属性,可任意比例缩放。
ws.setUseWideViewPort(true);
//缩放比例 1
webView.setInitialScale(1);
// 告诉WebView启用JavaScript执行。默认的是false。
ws.setJavaScriptEnabled(true);
// 页面加载好以后,再放开图片
ws.setBlockNetworkImage(false);
// 使用localStorage则必须打开,开启DOM缓存
ws.setDomStorageEnabled(true);
//排版适应屏幕
ws.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
// WebView是否支持多个窗口。
ws.setSupportMultipleWindows(true);
// webView从5.0开始默认不允许混合模式,https中不能加载http资源,需要设置开启。
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
ws.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
}
/** 设置字体默认缩放大小(改变网页字体大小,setTextSize api14被弃用)*/
ws.setTextZoom(100);
mWebChromeClient = new MyWebChromeClient(this);
//WebChromeClient专门用来辅助WebView处理Javascript
webView.setWebChromeClient(mWebChromeClient);
//与js交互
webView.addJavascriptInterface(new ImageClickInterface(this), "injectedObject");
webView.setWebViewClient(new MyWebViewClient(this));
}
示例15: initWebView
import android.webkit.WebSettings; //导入方法依赖的package包/类
private void initWebView() {
mProgressBar.setVisibility(View.VISIBLE);
WebSettings ws = mWebView.getSettings();
// 网页内容的宽度是否可大于WebView控件的宽度
ws.setLoadWithOverviewMode(false);
// 保存表单数据
ws.setSaveFormData(true);
// 是否应该支持使用其屏幕缩放控件和手势缩放
ws.setSupportZoom(true);
ws.setBuiltInZoomControls(true);
ws.setDisplayZoomControls(false);
// 启动应用缓存
ws.setAppCacheEnabled(true);
// 设置缓存模式
ws.setCacheMode(WebSettings.LOAD_DEFAULT);
// setDefaultZoom api19被弃用
// 设置此属性,可任意比例缩放。
ws.setUseWideViewPort(true);
// 缩放比例 1
mWebView.setInitialScale(1);
// 告诉WebView启用JavaScript执行。默认的是false。
ws.setJavaScriptEnabled(true);
// 页面加载好以后,再放开图片
ws.setBlockNetworkImage(false);
// 使用localStorage则必须打开
ws.setDomStorageEnabled(true);
// 排版适应屏幕
ws.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
// WebView是否支持多个窗口。
ws.setSupportMultipleWindows(true);
// webview从5.0开始默认不允许混合模式,https中不能加载http资源,需要设置开启。
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
ws.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
}
/** 设置字体默认缩放大小(改变网页字体大小,setTextSize api14被弃用)*/
ws.setTextZoom(100);
mWebChromeClient = new MyWebChromeClient(this);
mWebView.setWebChromeClient(mWebChromeClient);
// 与js交互
mWebView.addJavascriptInterface(new ImageClickInterface(this), "injectedObject");
mWebView.setWebViewClient(new MyWebViewClient(this));
}