本文整理匯總了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);
}
示例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(){
});
}
示例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(){
});
}
示例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);
}
示例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");
}
示例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);
}
示例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);
}
示例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);
}
示例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;
});
}
示例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;
}
});
}
示例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));
}
示例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();
}
});
}
示例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());
}
示例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);
}
示例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);
}