当前位置: 首页>>代码示例>>Java>>正文


Java WebSettings类代码示例

本文整理汇总了Java中com.tencent.smtt.sdk.WebSettings的典型用法代码示例。如果您正苦于以下问题:Java WebSettings类的具体用法?Java WebSettings怎么用?Java WebSettings使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


WebSettings类属于com.tencent.smtt.sdk包,在下文中一共展示了WebSettings类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
    }
}
 
开发者ID:snailycy,项目名称:AndroidHybridLib,代码行数:23,代码来源:WrapperWebView.java

示例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);
}
 
开发者ID:jianesrq0724,项目名称:UpdateLibrary,代码行数:22,代码来源:X5WebView.java

示例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();
}
 
开发者ID:jianesrq0724,项目名称:UpdateLibrary,代码行数:28,代码来源:X5WebViewBrowseActivity.java

示例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);
}
 
开发者ID:banwenmang,项目名称:X5web,代码行数:18,代码来源:X5WebView.java

示例5: init

import com.tencent.smtt.sdk.WebSettings; //导入依赖的package包/类
@Override
protected void init() {
    String link=getIntent().getStringExtra("link");
    tvTitle.setText(getIntent().getStringExtra("title"));
    WebSettings webSettings = mWvNewsContent.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);

    mWvNewsContent.setWebViewClient(new WebViewClient(){
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return true;
        }
    });

    mWvNewsContent.loadUrl(link);
    setListenr();
}
 
开发者ID:ydmmocoo,项目名称:StudyApp,代码行数:20,代码来源:NewDetailActivity.java

示例6: initWebConfig

import com.tencent.smtt.sdk.WebSettings; //导入依赖的package包/类
private void initWebConfig() {
    WebSettings settings = webView.getSettings();
    settings.setJavaScriptEnabled(true);
    settings.setLoadWithOverviewMode(true);
    settings.setAppCacheEnabled(true);
    settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
    settings.setSupportZoom(true);
    webView.setWebViewClient(new WebViewClient() {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return true;
        }
    });

}
 
开发者ID:arieshao,项目名称:Integration,代码行数:17,代码来源:DetailActivity.java

示例7: invokeHtml5

import com.tencent.smtt.sdk.WebSettings; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
private void invokeHtml5(WebSettings setting) {
    try {
        String path = mBrwView.getContext().getDir("database", 0).getPath();
        Class[] paramTypes = new Class[]{boolean.class};
        Class[] param1 = new Class[]{String.class};
        Method databaseEnabled = WebSettings.class.getMethod("setDatabaseEnabled", paramTypes);
        databaseEnabled.invoke(setting, true);
        Method domStorageEnabled = WebSettings.class.getMethod("setDomStorageEnabled", paramTypes);
        domStorageEnabled.invoke(setting, true);
        Method databasePath = WebSettings.class.getMethod("setDatabasePath", param1);
        databasePath.invoke(setting, path);
    } catch (Exception e) {
        ;
    }
}
 
开发者ID:AppCanOpenSource,项目名称:appcan-android,代码行数:17,代码来源:EBrowserSetting.java

示例8: setUserAgent

import com.tencent.smtt.sdk.WebSettings; //导入依赖的package包/类
/**
 * 设置UserAgent
 *
 * @param appId
 * @param versionCode
 * @param language
 */
public void setUserAgent(String appId, int versionCode, String language) {
    if (mIsWhiteList) {
        WebSettings ws = mWebView.getSettings();
        StringBuilder uaSB = new StringBuilder();
        uaSB.append(ws.getUserAgentString());
        uaSB.append(appId);
        uaSB.append(".");
        uaSB.append(versionCode);
        uaSB.append(HybridConstant.USER_AGENT_LAN);
        uaSB.append(language);
        ws.setUserAgentString(uaSB.toString());
    }
}
 
开发者ID:snailycy,项目名称:AndroidHybridLib,代码行数:21,代码来源:WrapperWebView.java

示例9: setWebArticleCacheState

import com.tencent.smtt.sdk.WebSettings; //导入依赖的package包/类
public void setWebArticleCacheState(boolean isNeedCache) {
    if (isNeedCache) {
        getSettings().setAppCacheEnabled(true);
        getSettings().setDomStorageEnabled(true);
        getSettings().setDatabaseEnabled(true);
        if (NetWorkUtil.isNetWorkAvailable(getContext())) {
            getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
        } else {
            getSettings().setCacheMode(WebSettings.LOAD_CACHE_ONLY);
        }
        String cacheDir = getContext().getFilesDir().getAbsolutePath() + "web_cache";
        getSettings().setAppCachePath(cacheDir);
        getSettings().setAppCacheEnabled(true);
    }
}
 
开发者ID:HanyeeWang,项目名称:GeekZone,代码行数:16,代码来源:ArticleWebView.java

示例10: 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();
}
 
开发者ID:banwenmang,项目名称:X5web,代码行数:36,代码来源:BrowserActivity.java

示例11: setUserAgent

import com.tencent.smtt.sdk.WebSettings; //导入依赖的package包/类
@Override
public void setUserAgent(String userAgent) {
    if (TextUtil.isNotEmpty(userAgent)) {
        WebSettings settings = mWebView.getSettings();
        settings.setUserAgentString(settings.getUserAgentString() + " " + userAgent);
    }
}
 
开发者ID:joy-inc,项目名称:core-web,代码行数:8,代码来源:BaseWebX5Presenter.java

示例12: initViews

import com.tencent.smtt.sdk.WebSettings; //导入依赖的package包/类
private void initViews() {

        WebSettings settings = getSettings();
        settings.setAppCacheEnabled(true);
        settings.setDomStorageEnabled(true);
        settings.setDatabaseEnabled(true);
        if (SystemUtil.isNetworkConnected()) {
            settings.setCacheMode(WebSettings.LOAD_DEFAULT);
        } else {
            settings.setCacheMode(WebSettings.LOAD_CACHE_ONLY);
        }
        settings.setJavaScriptEnabled(true);
        settings.setLoadWithOverviewMode(true);
        settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
        settings.setSupportZoom(true);

        mProgressView = new ProgressBar(getContext(), null, android.R.attr.progressBarStyleHorizontal);
        mProgressView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, 10));
        mProgressView.setBackgroundColor(progressColor);
        addView(mProgressView);

        setWebChromeClient(new WebChromeClient() {
            @Override
            public void onProgressChanged(WebView view, int newProgress) {
                super.onProgressChanged(view, newProgress);
                if (newProgress == 100) {
                    mProgressView.setVisibility(GONE);
                } else {
                    if (mProgressView.getVisibility() == GONE)
                        mProgressView.setVisibility(VISIBLE);
                    mProgressView.setProgress(newProgress);
                }
            }
        });
    }
 
开发者ID:a396901990,项目名称:Article-Comment,代码行数:36,代码来源:XProgressWebView.java

示例13: 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);


   }
 
开发者ID:stytooldex,项目名称:stynico,代码行数:54,代码来源:x5_WebviewSelfAdaption.java

示例14: init

import com.tencent.smtt.sdk.WebSettings; //导入依赖的package包/类
private void init() {
        web_view = (WebView) mView.findViewById(R.id.forum_WebView);
        mProgressBar = (ProgressBar) mView.findViewById(R.id.progressBar);
////        c)以下接口禁止(直接或反射)调用,避免视频画面无法显示:
//        web_view.setLayerType(View.LAYER_TYPE_SOFTWARE,new Paint());
//        web_view.setDrawingCacheEnabled(true);
//        设置可以在webview中加载网页中的连接

        web_view.setWebChromeClient(new WebChromeClient() {
            @Override
            public void onProgressChanged(WebView view, int newProgress) {
                mProgressBar.setProgress(newProgress);
                if (newProgress == 100) {
//                    网页加载完成,关闭对话框
                    mProgressBar.setVisibility(View.GONE);
                    isLazy=false;
                    Log.d("forumFragment", "加载成功");
                } else {
                    //网页加载中,打开进度对话框
                    mProgressBar.setVisibility(View.VISIBLE);
                }
            }
        }
        );
        //启用支持javascript
        WebSettings settings = web_view.getSettings();
        settings.setJavaScriptEnabled(true);
        settings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
        /*web_view.setOnKeyListener(new WebView.OnKeyListener() {
            @Override
            public boolean onKey(View v, int keyCode, KeyEvent event) {
                Log.d("forumFragment", "我进来了");
                if (keyCode == KeyEvent.KEYCODE_BACK ) {
                    if (web_view != null && web_view.canGoBack()) {
                        web_view.goBack();
                        return true;
                    }
                }
                return false;
            }//换成腾讯的TBS之后,键盘监听失效了
        });*/
    }
 
开发者ID:v991314,项目名称:3DGameInfo,代码行数:43,代码来源:forumFragment.java

示例15: 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
                        + "&nbsp&nbsp"
                        + "发布时间:" + mDate
                        + "&nbsp&nbsp"
                        + "来源:" + 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);

        }
    }
 
开发者ID:v991314,项目名称:3DGameInfo,代码行数:49,代码来源:ChapterDetailActivity.java


注:本文中的com.tencent.smtt.sdk.WebSettings类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。