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


Java WebSettings.setBlockNetworkImage方法代码示例

本文整理汇总了Java中android.webkit.WebSettings.setBlockNetworkImage方法的典型用法代码示例。如果您正苦于以下问题:Java WebSettings.setBlockNetworkImage方法的具体用法?Java WebSettings.setBlockNetworkImage怎么用?Java WebSettings.setBlockNetworkImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.webkit.WebSettings的用法示例。


在下文中一共展示了WebSettings.setBlockNetworkImage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initViews

import android.webkit.WebSettings; //导入方法依赖的package包/类
private void initViews() {
        LayoutInflater.from(getContext()).inflate(R.layout.view_webview, this, true);
        mWebView = (MyWebView) findViewById(R.id.webview);
        mProgressBar = (ProgressBar) findViewById(R.id.progressbar);
        mWebView.setWebViewClient(new MyClient());
//        mWebView.setWebChromeClient(new MyWebChromeClient());
        WebSettings webSettings = mWebView.getSettings();
        webSettings.setJavaScriptEnabled(true);
        webSettings.setRenderPriority(WebSettings.RenderPriority.HIGH);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            webSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
        }
        webSettings.setBlockNetworkImage(true);
        mWebView.setOnScrollBottomListener(this);
        webSettings.setCacheMode(WebSettings.LOAD_DEFAULT);
    }
 
开发者ID:SavorGit,项目名称:Hotspot-master-devp,代码行数:17,代码来源:CustomWebView.java

示例2: initWebView

import android.webkit.WebSettings; //导入方法依赖的package包/类
private void initWebView() {
    WebSettings webSettings = mWebView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    /*使webview能够加载图片*/
    webSettings.setBlockNetworkImage(false);
    webSettings.setAppCacheEnabled(true);
    mDialog=new SpotsDialog(this);
    mDialog.show();
    mWebView.loadUrl(mMessage.getClickUrl());
    //        mWebAppInterface = new WebAppInterface(this);
    //        mWebView.addJavascriptInterface(mWebAppInterface, "appInterface");
    mWebView.setWebViewClient(new MyWebChromeC());
    mWebView.setWebChromeClient(new WebChromeClient(){

    });

}
 
开发者ID:yiwent,项目名称:Mobike,代码行数:18,代码来源:TripDetailActivity.java

示例3: initWebView

import android.webkit.WebSettings; //导入方法依赖的package包/类
private void initWebView() {
        WebSettings webSettings = mWebView.getSettings();
        webSettings.setJavaScriptEnabled(true);
        /*使webview能够加载图片*/
        webSettings.setBlockNetworkImage(false);
        webSettings.setAppCacheEnabled(true);
        mDialog=new SpotsDialog(this);
        mDialog.show();
        mWebView.loadUrl(mMessage.getClickUrl());
//        mWebAppInterface = new WebAppInterface(this);
//        mWebView.addJavascriptInterface(mWebAppInterface, "appInterface");
        mWebView.setWebViewClient(new MyWebChromeC());
        mWebView.setWebChromeClient(new WebChromeClient(){

        });

    }
 
开发者ID:yiwent,项目名称:Mobike,代码行数:18,代码来源:MessageDetailActivity.java

示例4: initViews

import android.webkit.WebSettings; //导入方法依赖的package包/类
private void initViews() {
        LayoutInflater.from(getContext()).inflate(R.layout.view_webview_default, this, true);
        mWebView = (MyWebView) findViewById(R.id.webview);
        mProgressBar = (ProgressBar) findViewById(R.id.progressbar);
        mProgressBar.setVisibility(VISIBLE);
        mWebView.setWebViewClient(new MyClient());
        mWebView.setWebChromeClient(new MyWebChromeClient());
        WebSettings webSettings = mWebView.getSettings();
//        webSettings.setJavaScriptCanOpenWindowsAutomatically(false);
        webSettings.setJavaScriptEnabled(true);
        webSettings.setRenderPriority(WebSettings.RenderPriority.HIGH);
//        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
//            webSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
//        }
        webSettings.setBlockNetworkImage(true);
        mWebView.setOnScrollBottomListener(this);
//        mWebView.setLayerType(View.La, null);
//        mWebView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
//        mWebView.setVerticalScrollBarEnabled(true);
//        mWebView.setHorizontalScrollBarEnabled(false);
         webSettings.setSupportZoom(false);
//        webSettings.setBlockNetworkImage(true);
         webSettings.setDomStorageEnabled(true);
//        webSettings.setRenderPriority(WebSettings.RenderPriority.HIGH);
//        webSettings.setPluginState(WebSettings.PluginState.ON);
        webSettings.setDefaultTextEncodingName("UTF-8");
        webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE);
    }
 
开发者ID:SavorGit,项目名称:Hotspot-master-devp,代码行数:29,代码来源:DefaultWebView.java

示例5: WebViewTask

import android.webkit.WebSettings; //导入方法依赖的package包/类
public WebViewTask(Context context) {
    webView = new WebView(context);
    webView.addJavascriptInterface(new InJavaScriptLocalObj(), "get_source");
    webView.setWebViewClient(new WebViewClient() {
        @Override
        public void onPageFinished(WebView view, String url) {
            webView.loadUrl("javascript:window.get_source.getSource('<head>'+document.getElementsByTagName('html')[0].innerHTML+'</head>');");
        }
    });
    WebSettings webSettings = webView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webSettings.setDomStorageEnabled(true);
    webSettings.setBlockNetworkImage(true);
    webSettings.setUserAgentString("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.109 Safari/537.36");
}
 
开发者ID:lanyuanxiaoyao,项目名称:PicKing,代码行数:16,代码来源:WebViewTask.java

示例6: onPageStarted

import android.webkit.WebSettings; //导入方法依赖的package包/类
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
    if (mIsBlockImageLoad){
        WebSettings webSettings = view.getSettings();
        webSettings.setBlockNetworkImage(true);
    }
    if (mCustomWebViewClient!=null){
        mCustomWebViewClient.onPageStarted(view,url,favicon);
        return;
    }
    super.onPageStarted(view, url, favicon);
}
 
开发者ID:yale8848,项目名称:CacheWebView,代码行数:13,代码来源:CacheWebViewClient.java

示例7: onPageFinished

import android.webkit.WebSettings; //导入方法依赖的package包/类
@Override
public void onPageFinished(WebView view, String url) {
    if (mIsBlockImageLoad){
        WebSettings webSettings = view.getSettings();
        webSettings.setBlockNetworkImage(false);
    }
    if (mCustomWebViewClient!=null){
        mCustomWebViewClient.onPageFinished(view,url);
        return;
    }
    super.onPageFinished(view, url);
}
 
开发者ID:yale8848,项目名称:CacheWebView,代码行数:13,代码来源:CacheWebViewClient.java

示例8: 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);
}
 
开发者ID:yangchong211,项目名称:YCUtils,代码行数:40,代码来源:KnowledgeOtherFragment.java

示例9: initView

import android.webkit.WebSettings; //导入方法依赖的package包/类
@SuppressLint("SetJavaScriptEnabled") private void initView(@Nullable AttributeSet attrs) {
    if (isInEditMode()) return;
    if (attrs != null) {
        TypedArray tp = getContext().obtainStyledAttributes(attrs, R.styleable.PrettifyWebView);
        try {
            int color = tp.getColor(R.styleable.PrettifyWebView_webview_background, ViewHelper.getWindowBackground(getContext()));
            setBackgroundColor(color);
        } finally {
            tp.recycle();
        }
    }
    setWebChromeClient(new ChromeClient());
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
        setWebViewClient(new WebClient());
    } else {
        setWebViewClient(new WebClientCompat());
    }
    WebSettings settings = getSettings();
    settings.setJavaScriptEnabled(true);
    settings.setAppCachePath(getContext().getCacheDir().getPath());
    settings.setAppCacheEnabled(true);
    settings.setCacheMode(WebSettings.LOAD_NO_CACHE);
    settings.setDefaultTextEncodingName("utf-8");
    settings.setLoadsImagesAutomatically(true);
    settings.setBlockNetworkImage(false);
    setOnLongClickListener((view) -> {
        WebView.HitTestResult result = getHitTestResult();
        if (hitLinkResult(result) && !InputHelper.isEmpty(result.getExtra())) {
            AppHelper.copyToClipboard(getContext(), result.getExtra());
            return true;
        }
        return false;
    });
}
 
开发者ID:duyp,项目名称:mvvm-template,代码行数:35,代码来源:PrettifyWebView.java

示例10: init

import android.webkit.WebSettings; //导入方法依赖的package包/类
@SuppressLint("SetJavaScriptEnabled")
private void init(AttributeSet attrs) {
    if (attrs != null) {
        TypedArray tp = getContext().obtainStyledAttributes(attrs, R.styleable.CodeWebView);
        try {
            backgroundColor = tp.getColor(R.styleable.CodeWebView_webview_background,
                    ViewUtils.getWindowBackground(getContext()));
            setBackgroundColor(backgroundColor);
        } finally {
            tp.recycle();
        }
    }

    setWebChromeClient(new ChromeClient());
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
        setWebViewClient(new WebClientN());
    } else {
        setWebViewClient(new WebClient());
    }
    WebSettings settings = getSettings();
    settings.setJavaScriptEnabled(true);
    settings.setAppCachePath(getContext().getCacheDir().getPath());
    settings.setAppCacheEnabled(true);
    settings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
    settings.setDefaultTextEncodingName("utf-8");
    settings.setLoadsImagesAutomatically(true);
    settings.setBlockNetworkImage(false);
    setOnLongClickListener(new OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            WebView.HitTestResult result = getHitTestResult();
            if (hitLinkResult(result) && !StringUtils.isBlank(result.getExtra())) {
                AppUtils.copyToClipboard(getContext(), result.getExtra());
                return true;
            }
            return false;
        }
    });
}
 
开发者ID:ThirtyDegreesRay,项目名称:OpenHub,代码行数:40,代码来源:CodeWebView.java

示例11: 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));
}
 
开发者ID:joelan,项目名称:ClouldReader,代码行数:45,代码来源:WebViewActivity.java

示例12: init

import android.webkit.WebSettings; //导入方法依赖的package包/类
private void init(Context context) {
	mContext = context;
	mLayout = new FrameLayout(context);
	mBrowserFrameLayout = (FrameLayout) LayoutInflater.from(context)
			.inflate(R.layout.common_custom_screen, null);
	wv_imgbtn_back = (LinearLayout) mBrowserFrameLayout.findViewById(R.id.top_bar_linear_back);
	wv_tv_title = (TextView) mBrowserFrameLayout.findViewById(R.id.top_bar_title);
	mContentView = (FrameLayout) mBrowserFrameLayout
			.findViewById(R.id.main_content);
	mCustomViewContainer = (FrameLayout) mBrowserFrameLayout
			.findViewById(R.id.fullscreen_custom_content);
	frame_progress = (FrameLayout) mBrowserFrameLayout
			.findViewById(R.id.frame_progress);
	webview_tv_progress = (TextView) frame_progress
			.findViewById(R.id.webview_tv_progress);
	final FrameLayout.LayoutParams COVER_SCREEN_PARAMS = new FrameLayout.LayoutParams(
			ViewGroup.LayoutParams.MATCH_PARENT,
			ViewGroup.LayoutParams.MATCH_PARENT, Gravity.CENTER);
	mLayout.addView(mBrowserFrameLayout, COVER_SCREEN_PARAMS);
	mWebChromeClient = new MyWebChromeClient();
	setWebChromeClient(mWebChromeClient);
	setWebViewClient(new MyWebViewClient());
	WebSettings webSettings = this.getSettings();
	webSettings.setJavaScriptEnabled(true);  //开启javascript
	webSettings.setDomStorageEnabled(true);  //开启DOM
	webSettings.setDefaultTextEncodingName("utf-8"); //设置编码
	// // web页面处理
	webSettings.setAllowFileAccess(true);// 支持文件流
	// webSettings.setSupportZoom(true);// 支持缩放
	// webSettings.setBuiltInZoomControls(true);// 支持缩放
	webSettings.setUseWideViewPort(true);// 调整到适合webview大小
	webSettings.setLoadWithOverviewMode(true);// 调整到适合webview大小
	webSettings.setDefaultZoom(ZoomDensity.FAR);// 屏幕自适应网页,如果没有这个,在低分辨率的手机上显示可能会异常
	webSettings.setRenderPriority(RenderPriority.HIGH);
	//提高网页加载速度,暂时阻塞图片加载,然后网页加载好了,在进行加载图片
	webSettings.setBlockNetworkImage(true);
	//开启缓存机制
	webSettings.setAppCacheEnabled(true);
	//根据当前网页连接状态
	 if(StrUtils.getAPNType(context)== StrUtils.WIFI){
	 //设置无缓存
	 webSettings.setCacheMode(WebSettings.LOAD_DEFAULT);
	 }else{
	 //设置缓存
	 webSettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
	 }
	mContentView.addView(this);
	// 返回
	wv_imgbtn_back.setOnClickListener(new OnClickListener() {
		@Override
		public void onClick(View v) {
			closeAdWebPage();
		}
	});
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:56,代码来源:HTML5CustomWebView.java

示例13: initWebView

import android.webkit.WebSettings; //导入方法依赖的package包/类
private void initWebView(){

        WebSettings settings = mWebView.getSettings();

        settings.setJavaScriptEnabled(true);
        settings.setBlockNetworkImage(false);
        settings.setAppCacheEnabled(true);


        mWebView.loadUrl(Contants.API.WARES_DETAIL);

        mAppInterfce = new WebAppInterface(this);
        mWebView.addJavascriptInterface(mAppInterfce,"appInterface");
        mWebView.setWebViewClient(new WC());


    }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:WareDetailActivity.java

示例14: initWebSetting

import android.webkit.WebSettings; //导入方法依赖的package包/类
/**
 * 初始化WebSetting
 *
 * @param settings WebSetting
 */
protected void initWebSetting(WebSettings settings) {
    // 缩放至屏幕的大小
    settings.setLoadWithOverviewMode(true);
    // 保存表单数据
    settings.setSaveFormData(true);
    // 是否应该支持使用其屏幕缩放控件和手势缩放
    settings.setSupportZoom(true);
    //        //是否支持手势缩放控制
    //        settings.setBuiltInZoomControls(true);
    //        是否隐藏原生的缩放控件
    //        settings.setDisplayZoomControls(false);
    // 启动应用缓存
    settings.setAppCacheEnabled(true);
    // 排版适应屏幕,只显示一列
    settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
    //        settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
    //  页面加载好以后,再放开图片
    settings.setBlockNetworkImage(false);
    // 使用localStorage则必须打开
    settings.setDomStorageEnabled(true);
    settings.setDatabaseEnabled(true);
    // WebView启用JavaScript执行。默认的是false。
    settings.setJavaScriptEnabled(true); // 设置支持javascript脚本
    settings.setJavaScriptCanOpenWindowsAutomatically(true);
    if (NetworkConnectionUtils.isConnected(mContext)) {
        settings.setCacheMode(WebSettings.LOAD_DEFAULT);
    } else {
        settings.setCacheMode(WebSettings.LOAD_CACHE_ONLY);
    }

    //        settings.setBlockNetworkImage(false);
    //        settings.setAppCacheEnabled(true);
    //        settings.setDomStorageEnabled(true);
    //        settings.setDatabaseEnabled(true);
    //        if (NetworkConnectionUtils.isConnected(mContext)) {
    //            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);
}
 
开发者ID:Horrarndoo,项目名称:YiZhi,代码行数:50,代码来源:BaseWebViewLoadActivity.java

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


}
 
开发者ID:zhao-mingjian,项目名称:qvod,代码行数:52,代码来源:WebViewPresenter.java


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