Java Code Examples for com.tencent.smtt.sdk.WebSettings#setSupportMultipleWindows()

The following examples show how to use com.tencent.smtt.sdk.WebSettings#setSupportMultipleWindows() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: X5WebView.java    From TBSVideoPlay with Apache License 2.0 6 votes vote down vote up
/**
 * 初始化webview设置
 */
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);
}
 
Example 2
Source File: X5WebView.java    From polyvideo with Apache License 2.0 6 votes vote down vote up
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);

	// this.getSettingsExtension().setPageCacheCapacity(IX5WebSettings.DEFAULT_CACHE_CAPACITY);//extension
	// settings 的设计
}
 
Example 3
Source File: X5WebView.java    From Readhub with Apache License 2.0 6 votes vote down vote up
private void initWebViewSettings() {
	WebSettings webSetting = this.getSettings();
	webSetting.setJavaScriptEnabled(true);
	webSetting.setJavaScriptCanOpenWindowsAutomatically(true);
	webSetting.setAllowFileAccess(true);
	webSetting.setLayoutAlgorithm(LayoutAlgorithm.NARROW_COLUMNS);
	webSetting.setSupportZoom(false);
	webSetting.setBuiltInZoomControls(false);
	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);

}
 
Example 4
Source File: X5WebView.java    From FastAndroid with Apache License 2.0 6 votes vote down vote up
@SuppressLint("SetJavaScriptEnabled")
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);

    // this.getSettingsExtension().setPageCacheCapacity(IX5WebSettings.DEFAULT_CACHE_CAPACITY);//extension
    // settings 的设计
}
 
Example 5
Source File: X5WebView.java    From CacheWebView with MIT License 6 votes vote down vote up
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);

    // this.getSettingsExtension().setPageCacheCapacity(IX5WebSettings.DEFAULT_CACHE_CAPACITY);//extension
    // settings 的设计
}
 
Example 6
Source File: x5_MainActivity.java    From styT with Apache License 2.0 5 votes vote down vote up
@SuppressLint("SetJavaScriptEnabled")
private void initWebSettings() {

    WebSettings settings = sMm.getSettings();
    //sMm.setLayerType();
    sMm.setDrawingCacheEnabled(true);
    //支持获取手势焦点
    sMm.requestFocusFromTouch();
    //支持JS
    settings.setJavaScriptEnabled(true);
    //支持插件
    //settings.setUserAgentString("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

    // 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(false);
    //设置缓存模式
    settings.setGeolocationEnabled(true);//允许地理位置可用
    settings.setDomStorageEnabled(true);
    settings.setDatabaseEnabled(true);
    settings.setCacheMode(WebSettings.LOAD_DEFAULT);
    settings.setAppCacheEnabled(true);
    settings.setAppCachePath(sMm.getContext().getCacheDir().getAbsolutePath());
    //settings.setRenderPriority(WebSettings.RenderPriority.HIGH);  //提高渲染的优先级
    //设置可访问文件
    settings.setAllowFileAccess(true);
    //当webview调用requestFocus时为webview设置节点
    settings.setNeedInitialFocus(true);

}
 
Example 7
Source File: WebViewFragment.java    From Dainty with Apache License 2.0 5 votes vote down vote up
@SuppressLint("SetJavaScriptEnabled")
private void setSettings(WebSettings setting) {
    //noinspection deprecation
    setting.setJavaScriptEnabled(true);
    setting.setJavaScriptCanOpenWindowsAutomatically(true);
    setting.setAllowFileAccess(true);
    setting.setSupportZoom(true);
    setting.setBuiltInZoomControls(true);   //允许放大缩小
    setting.setDisplayZoomControls(false);    //去掉放大缩小框
    setting.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
    setting.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
    setting.setSupportMultipleWindows(false);

    setting.setGeolocationEnabled(true);   //允许启用地理定位
    setting.setGeolocationDatabasePath(getActivity().getDir("geolocation", 0).getPath());
    setting.setSaveFormData(true);  //支持保存自动填充的表单数据
    setting.setDomStorageEnabled(true);  //支持DOM缓存
    setting.setDatabaseEnabled(true);
    setting.setAppCacheEnabled(true);
    setting.setAppCacheMaxSize(Long.MAX_VALUE);
    setting.setAppCachePath(getActivity().getDir("dainty_cache", 0).getPath());

    // 全屏显示
    setting.setUseWideViewPort(true);
    setting.setTextZoom(Integer.valueOf(PreferenceManager.getDefaultSharedPreferences(getContext()).getString("text_size", "100")));

}
 
Example 8
Source File: WebviewActivity.java    From AndroidFrame with Apache License 2.0 4 votes vote down vote up
private void initWebview() {
    mWebView = findViewById(R.id.webview);
    mBridge = new WebViewJavascriptBridge(this, sHandler, mWebView);
    mWebView.addJavascriptInterface(mBridge, "AndroidWebViewJavascriptBridge");
    WebSettings webSetting = mWebView.getSettings();
    webSetting.setJavaScriptEnabled(true);
    webSetting.setJavaScriptCanOpenWindowsAutomatically(true);
    webSetting.setAllowFileAccess(true);
    webSetting.setLayoutAlgorithm(WebSettings.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);
    String userAgent = webSetting.getUserAgentString() + " " + AGENG_STR
            + AGENG_STR_SUFFIX + "/" + getVersionName() + "/QD"
            + getQudaoName() + "/";
    webSetting.setUserAgentString(userAgent);
    mWebView.setWebViewClient(new WebViewClient() {
        @Override
        public void onPageFinished(WebView webView, String s) {
            InputStream fs = WebviewActivity.this.getResources().openRawResource(
                    R.raw.jsbridge_init);
            String jsbridgeInitScript = getLocalText(fs);
            String js1 = "javascript:var evtAndroidJSB = document.createEvent('Event');"
                    + "evtAndroidJSB.initEvent('AndroidWebViewJavascriptBridgeReady', false, false); "
                    + "document.dispatchEvent(evtAndroidJSB);";
            String js2 = "javascript: " + jsbridgeInitScript;
            if (android.os.Build.VERSION.SDK_INT <= 18) {
                mWebView.loadUrl(js1);
                mWebView.loadUrl(js2);
            } else {
                mWebView.evaluateJavascript(js1, null);
                mWebView.evaluateJavascript(js2, null);
            }
            super.onPageFinished(webView, s);
        }
    });
}
 
Example 9
Source File: CrazyDailyWebView.java    From CrazyDaily with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("all")
private void init(Context context) {
    WebSettings setttings = getSettings();
    setttings.setJavaScriptEnabled(true);//打开js
    setttings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);//设置布局
    setttings.setDomStorageEnabled(true);//打开Dom Storage
    setttings.setDatabaseEnabled(true);//打开Database
    setttings.setAppCacheEnabled(true);//打开App Cache
    setttings.setAppCacheMaxSize(Long.MAX_VALUE);
    File cacheDir = new File(context.getExternalCacheDir(), CacheConstant.CACHE_DIR_WEB);
    if (!cacheDir.exists()) {
        cacheDir.mkdirs();
    }
    setttings.setAppCachePath(cacheDir.getAbsolutePath());//设置App Cache缓存目录
    setttings.setSupportMultipleWindows(false);//不支持多窗口
    setttings.setJavaScriptCanOpenWindowsAutomatically(true);//支持js打开新窗口
    setttings.setAllowFileAccess(true);//启用WebView访问文件数据
    setttings.setSupportZoom(true);//支持缩放
    setttings.setDisplayZoomControls(false);//隐藏webview缩放按钮
    setttings.setBuiltInZoomControls(true);//支持手势缩放
    setttings.setLoadWithOverviewMode(true);//缩放至屏幕大小
    setttings.setUseWideViewPort(true);//调整屏幕自适应
    setttings.setDefaultTextEncodingName("utf-8");//设置编码格式为utf-8
    setttings.setLoadsImagesAutomatically(true);//支持自动加载图片
    setttings.setSavePassword(false);//禁止密码保存在本地
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        // https中支持访问http
        setttings.setMixedContentMode(android.webkit.WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        // 支持第三方的cookie同步
        CookieManager.getInstance().setAcceptThirdPartyCookies(this, true);
    }
    String ua = setttings.getUserAgentString();
    setttings.setUserAgentString(String.format("%s CrazyDaily %s", ua, DeviceUtil.getVersionName()));//重置ua
    setWebViewClient(new CrazyDailyWebViewClient());
    setWebChromeClient(new CrazyDailyWebChromeClient());
    setDownloadListener(new DownloadListener() {
        @Override
        public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimeType, long contentLength) {
            if (mDownloadCallback != null) {
                mDownloadCallback.onDownload(url, contentLength);
            }
        }
    });
}