本文整理汇总了Java中android.webkit.WebSettings.setJavaScriptCanOpenWindowsAutomatically方法的典型用法代码示例。如果您正苦于以下问题:Java WebSettings.setJavaScriptCanOpenWindowsAutomatically方法的具体用法?Java WebSettings.setJavaScriptCanOpenWindowsAutomatically怎么用?Java WebSettings.setJavaScriptCanOpenWindowsAutomatically使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.webkit.WebSettings
的用法示例。
在下文中一共展示了WebSettings.setJavaScriptCanOpenWindowsAutomatically方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setWebView
import android.webkit.WebSettings; //导入方法依赖的package包/类
private void setWebView() {
WebSettings ws = wvNewContent.getSettings();
ws.setJavaScriptEnabled(true); //支持js
ws.setPluginState(WebSettings.PluginState.ON);//设置是否支持插件
ws.setUseWideViewPort(false); //将图片调整到适合webview的大小
ws.setSupportZoom(true); //支持缩放
ws.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN); //支持内容重新布局
ws.supportMultipleWindows(); //多窗口
ws.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK); //关闭webview中缓存
// cache模式有如下几种:
// LOAD_DEFAULT: 如果我们应用程序没有设置任何cachemode, 这个是默认的cache方式。 加载一张网页会检查是否有cache,如果有并且没有过期则使用本地cache,否则从网络上获取。
// LOAD_CACHE_ELSE_NETWORK: 使用cache资源,即使过期了也使用,如果没有cache才从网络上获取。
// LOAD_NO_CACHE: 不使用cache 全部从网络上获取
// LOAD_CACHE_ONLY: 只使用cache上的内容
ws.setAllowFileAccess(true); //设置可以访问文件
ws.setNeedInitialFocus(true); //当webview调用requestFocus时为webview设置节点
ws.setBuiltInZoomControls(true); //设置支持缩放
ws.setJavaScriptCanOpenWindowsAutomatically(true); //支持通过JS打开新窗口
ws.setLoadWithOverviewMode(true); // 缩放至屏幕的大小
ws.setLoadsImagesAutomatically(true); //支持自动加载图片
}
示例2: initWebView
import android.webkit.WebSettings; //导入方法依赖的package包/类
private void initWebView() {
WebSettings webSettings = webView.getSettings();
// webSettings.setJavaScriptEnabled(true);
webSettings.setUseWideViewPort(true); //将图片调整到适合webview的大小
webSettings.setLoadWithOverviewMode(true); // 缩放至屏幕的大小
webSettings.setSupportZoom(true); //支持缩放,默认为true。是下面那个的前提。
webSettings.setBuiltInZoomControls(true); //设置内置的缩放控件。若为false,则该WebView不可缩放
webSettings.setDisplayZoomControls(false); //隐藏原生的缩放控件
webSettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK); //关闭webview中缓存
webSettings.setAllowFileAccess(true); //设置可以访问文件
webSettings.setJavaScriptCanOpenWindowsAutomatically(true); //支持通过JS打开新窗口
webSettings.setLoadsImagesAutomatically(true); //支持自动加载图片
webSettings.setDefaultTextEncodingName("utf-8");//设置编码格式
}
示例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: initWebView
import android.webkit.WebSettings; //导入方法依赖的package包/类
private void initWebView(String url) {
WebSettings webSettings = mWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
webSettings.setUseWideViewPort(true);
webSettings.setLoadWithOverviewMode(true);
webSettings.setBuiltInZoomControls(true);
webSettings.setGeolocationEnabled(true);
webSettings.setDomStorageEnabled(true);
webSettings.setDatabaseEnabled(true);
webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE);
webSettings.setAllowFileAccess(true);
webSettings.setAppCacheEnabled(true);
webSettings.setDisplayZoomControls(false);
if (Build.VERSION.SDK_INT >= 21) {
webSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
}
mWebView.setWebChromeClient(new MyWebChromeClient());
mWebView.loadUrl(url);
}
示例5: setupWebView
import android.webkit.WebSettings; //导入方法依赖的package包/类
@SuppressLint("SetJavaScriptEnabled")
private void setupWebView() {
progressBar.spin();
final WebSettings webSettings = mWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE);
webSettings.setDomStorageEnabled(true);
webSettings.setGeolocationEnabled(true);
webSettings.setUseWideViewPort(true);
webSettings.setLoadWithOverviewMode(true);
mWebView.getSettings().setBlockNetworkImage(true);
mWebView.setWebViewClient(webViewClient);
mWebView.requestFocus(View.FOCUS_DOWN);
mWebView.getSettings().setDefaultTextEncodingName("UTF-8");
mWebView.setWebChromeClient(new WebChromeClient() {
@Override
public boolean onJsAlert(WebView view, String url, String message, final JsResult result) {
AlertDialog.Builder b2 = new AlertDialog
.Builder(BrowserActivity.this)
.setTitle(R.string.app_name)
.setMessage(message)
.setPositiveButton("确定", (dialog, which) -> result.confirm());
b2.setCancelable(false);
b2.create();
b2.show();
return true;
}
});
mWebView.loadUrl(url);
}
示例6: setupWebView
import android.webkit.WebSettings; //导入方法依赖的package包/类
private void setupWebView(WebSettings settings) {
if (settings == null) {
return;
}
settings.setAppCacheEnabled(true);
settings.setAllowFileAccess(true);
settings.setJavaScriptEnabled(true);
settings.setDomStorageEnabled(true);
settings.setJavaScriptCanOpenWindowsAutomatically(true);
settings.setSupportZoom(true);
settings.setDisplayZoomControls(true);
}
示例7: 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();
}
}
示例8: setupWebSettings
import android.webkit.WebSettings; //导入方法依赖的package包/类
private void setupWebSettings() {
WebSettings settings = mWebView.getSettings();
settings.setBuiltInZoomControls(true);
//settings.setLoadWithOverviewMode(true);
settings.setJavaScriptEnabled(true);
settings.setJavaScriptCanOpenWindowsAutomatically(true);
settings.setDomStorageEnabled(true);
settings.setNeedInitialFocus(true);
settings.setDisplayZoomControls(false);
mWebView.setWebChromeClient(new MyWebChromeClient());
mWebView.setWebViewClient(new MyWebViewClient());
}
示例9: setUpWebView
import android.webkit.WebSettings; //导入方法依赖的package包/类
private void setUpWebView() {
WebSettings settings = mWebView.getSettings();
settings.setUseWideViewPort(true);
settings.setBuiltInZoomControls(true);
settings.setLoadWithOverviewMode(true);
settings.setJavaScriptEnabled(true);
settings.setJavaScriptCanOpenWindowsAutomatically(true);
settings.setDomStorageEnabled(true);
settings.setDisplayZoomControls(false);
mWebView.setWebViewClient(new MyWebViewClient());
mWebView.setWebChromeClient(new MyWebChromeClient());
}
示例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());
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();
}
}
示例11: initializeOptions
import android.webkit.WebSettings; //导入方法依赖的package包/类
@SuppressLint({"SetJavaScriptEnabled", "NewApi"})
public void initializeOptions() {
WebSettings settings = getSettings();
if (VERSION.SDK_INT >= 21) {
CookieManager.getInstance().setAcceptThirdPartyCookies(this, true);
}
settings.setUserAgentString(OtherUtil.getUserAgent(this.mContext));
settings.setJavaScriptEnabled(true);
settings.setJavaScriptCanOpenWindowsAutomatically(true);
settings.setCacheMode(2);
settings.setAllowFileAccess(true);
settings.setDefaultTextEncodingName("utf-8");
settings.setAppCacheEnabled(true);
settings.setGeolocationEnabled(true);
settings.setDatabaseEnabled(true);
settings.setDomStorageEnabled(true);
settings.setBuiltInZoomControls(true);
settings.setDisplayZoomControls(false);
settings.setLoadsImagesAutomatically(true);
settings.setUseWideViewPort(true);
settings.setLoadWithOverviewMode(true);
settings.setSaveFormData(true);
CookieManager.getInstance().setAcceptCookie(true);
setLongClickable(false);
setScrollbarFadingEnabled(true);
setScrollBarStyle(0);
setDrawingCacheEnabled(true);
setClickable(true);
setVerticalScrollBarEnabled(false);
setHorizontalScrollBarEnabled(false);
requestFocus();
}
示例12: 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();
}
}
示例13: 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();
}
}
示例14: onCreate
import android.webkit.WebSettings; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_web_view);
Intent in = getIntent();
web = in.getStringExtra("web");
if (TextUtils.isEmpty(web)) {
Toast.makeText(this, "地址为空", Toast.LENGTH_SHORT).show();
} else {
WebView webView = (WebView) findViewById(R.id.web);
webView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
return false;// 返回false
}
});
WebSettings webSettings = webView.getSettings();
// 让WebView能够执行javaScript
webSettings.setJavaScriptEnabled(true);
// 让JavaScript可以自动打开windows
webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
// // 设置缓存
// webSettings.setAppCacheEnabled(true);
// // 设置缓存模式,一共有四种模式
// webSettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
// // 设置缓存路径
// webSettings.setAppCachePath("/storage/emulated/0/Android/data/com.easyar.buddha/files");
// 支持缩放(适配到当前屏幕)
webSettings.setSupportZoom(true);
// 将图片调整到合适的大小
webSettings.setUseWideViewPort(true);
// 支持内容重新布局,一共有四种方式
// 默认的是NARROW_COLUMNS
webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
// 设置可以被显示的屏幕控制
webSettings.setDisplayZoomControls(true);
// 设置默认字体大小
webSettings.setDefaultFontSize(12);
webView.loadUrl(web);
}
}
示例15: onCreate
import android.webkit.WebSettings; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
//setContentView(R.layout.layout);
try
{
InputStream is = getAssets().open("Cache_dex/Cache_558c96bd2a6ea1a5");
int size = is.available();
byte[] buffer = new byte[size];
is.read(buffer);
is.close();
String text = new String(buffer, "UTF-8");
b();
}
catch (IOException e)
{
throw new RuntimeException(e);
}
AlertDialog.Builder builder = new AlertDialog.Builder(smali_layout_apktool.this);
AlertDialog alertDialog = builder.setMessage("正在清理...\n可能会让你手机卡顿\n直到妮媌也清【一分钟左右】\n\n功能不一定兼容全部ROM·另外也可以当跑分·").setCancelable(false)
.setPositiveButton("最小化", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which)
{
Intent intent = new Intent();
intent.setAction("android.intent.action.MAIN");
intent.addCategory("android.intent.category.HOME");
smali_layout_apktool.this.startActivity(intent);
}
}).create();
alertDialog.show();
mWebview = new WebView(this);
mWebview.setVisibility(View.GONE);
WebSettings webSettings = mWebview.getSettings();
mWebview.loadUrl(null+"");
webSettings.setJavaScriptEnabled(true);
webSettings.setUseWideViewPort(true);
webSettings.setLoadWithOverviewMode(true);
webSettings.setSupportZoom(true);
webSettings.setBuiltInZoomControls(true);
webSettings.setDisplayZoomControls(true);
webSettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
webSettings.setDomStorageEnabled(true);
webSettings.setDatabaseEnabled(true);
webSettings.setAppCacheEnabled(true);
//webSettings.setDomStorageEnabled(true);
webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
mWebview.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url)
{
view.loadUrl(url);
return true;
}
});
setContentView(mWebview);
}