android.webkit.WebSettings.setMixedContentMode()方法的使用及代码示例

x33g5p2x  于2022-02-02 转载在 其他  
字(11.0k)|赞(0)|评价(0)|浏览(423)

本文整理了Java中android.webkit.WebSettings.setMixedContentMode()方法的一些代码示例,展示了WebSettings.setMixedContentMode()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebSettings.setMixedContentMode()方法的具体详情如下:
包路径:android.webkit.WebSettings
类名称:WebSettings
方法名:setMixedContentMode

WebSettings.setMixedContentMode介绍

暂无

代码示例

代码示例来源:origin: TheFinestArtist/FinestWebView-Android

settings.setMixedContentMode(webViewMixedContentMode);

代码示例来源:origin: delight-im/Android-AdvancedWebView

@SuppressWarnings("static-method")
@SuppressLint("NewApi")
protected void setMixedContentAllowed(final WebSettings webSettings, final boolean allowed) {
  if (Build.VERSION.SDK_INT >= 21) {
    webSettings.setMixedContentMode(allowed ? WebSettings.MIXED_CONTENT_ALWAYS_ALLOW : WebSettings.MIXED_CONTENT_NEVER_ALLOW);
  }
}

代码示例来源:origin: Justson/AgentWeb

mWebSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
  webView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {

代码示例来源:origin: GcsSloop/diycode

private void initialize() {
  loadUrl("file:///android_asset/html/preview.html");
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
    getSettings().setAllowUniversalAccessFromFileURLs(true);
  }
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
  }
  setWebChromeClient(new WebChromeClient() {
    @SuppressLint("JavascriptInterface")
    @Override
    public void onProgressChanged(WebView view, int newProgress) {
      super.onProgressChanged(view, newProgress);
      if (newProgress == 100) {
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
          loadUrl(mPreviewText);
        } else {
          evaluateJavascript(mPreviewText, null);
        }
      }
    }
  });
}

代码示例来源:origin: wendux/DSBridge-Android

@SuppressLint({"SetJavaScriptEnabled", "AddJavascriptInterface"})
private void init() {
  APP_CACHE_DIRNAME = getContext().getFilesDir().getAbsolutePath() + "/webcache";
  WebSettings settings = getSettings();
  settings.setDomStorageEnabled(true);
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    CookieManager.getInstance().setAcceptThirdPartyCookies(this, true);
    settings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
  }
  settings.setAllowFileAccess(false);
  settings.setAppCacheEnabled(false);
  settings.setCacheMode(WebSettings.LOAD_NO_CACHE);
  settings.setJavaScriptEnabled(true);
  settings.setLoadWithOverviewMode(true);
  settings.setAppCachePath(APP_CACHE_DIRNAME);
  settings.setUseWideViewPort(true);
  super.setWebChromeClient(mWebChromeClient);
  addInternalJavascriptObject();
  if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN) {
    super.addJavascriptInterface(innerJavascriptInterface, BRIDGE_NAME);
  } else {
    // add dsbridge tag in lower android version
    settings.setUserAgentString(settings.getUserAgentString() + " _dsbridge");
  }
}

代码示例来源:origin: free46000/HybridFoundation

private void setMixedContent(WebSettings settings) {
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { // 允许http  https 混合图片加载
    settings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
  }
}

代码示例来源:origin: rignaneseleo/SlimSocial-for-Facebook

@SuppressWarnings("static-method")
@SuppressLint("NewApi")
protected void setMixedContentAllowed(final WebSettings webSettings, final boolean allowed) {
  if (Build.VERSION.SDK_INT >= 21) {
    webSettings.setMixedContentMode(allowed ? WebSettings.MIXED_CONTENT_ALWAYS_ALLOW : WebSettings.MIXED_CONTENT_NEVER_ALLOW);
  }
}

代码示例来源:origin: zhujian1989/gank.io

@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public void setMixLoad(){
mWebView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
}

代码示例来源:origin: jtmcn/archwiki-viewer

public WikiView(Context context, AttributeSet attrs) {
  super(context, attrs);
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && !isInEditMode()) {
    //this allows the webview to inject the css (otherwise it blocks it for security reasons)
    getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
  }
}

代码示例来源:origin: madreain/AndroidDream

private void initWebView() {
    webview.getSettings().setJavaScriptEnabled(true);

    //设置当一个安全站点企图加载来自一个不安全站点资源时WebView的行为 https与http
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
      webview.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
    }

    webview.getSettings().setRenderPriority(WebSettings.RenderPriority.HIGH);
    webview.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);  //设置 缓存模式
//        webview.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ONLY);
    // 开启 DOM storage API 功能
    webview.getSettings().setDomStorageEnabled(true);
    //开启 database storage API 功能
    webview.getSettings().setDatabaseEnabled(true);
    String cacheDirPath = Environment.getExternalStorageDirectory() + "/Madreain";
    //设置数据库缓存路径
    webview.getSettings().setDatabasePath(cacheDirPath);
    //设置  Application Caches 缓存目录
    webview.getSettings().setAppCachePath(cacheDirPath);
    //开启 Application Caches 功能
    webview.getSettings().setAppCacheEnabled(true);

    webview.getSettings().setUserAgentString(webview.getSettings().getUserAgentString() + Constants.MADREAIN_UA_EXTRA);
  }

代码示例来源:origin: madreain/AndroidDream

private void initWebView() {
    webview.getSettings().setJavaScriptEnabled(true);

    //设置当一个安全站点企图加载来自一个不安全站点资源时WebView的行为 https与http
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
      webview.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
    }

    webview.getSettings().setRenderPriority(WebSettings.RenderPriority.HIGH);
    webview.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);  //设置 缓存模式
//        webview.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ONLY);
    // 开启 DOM storage API 功能
    webview.getSettings().setDomStorageEnabled(true);
    //开启 database storage API 功能
    webview.getSettings().setDatabaseEnabled(true);
    String cacheDirPath = Environment.getExternalStorageDirectory() + "/Madreain";
    //设置数据库缓存路径
    webview.getSettings().setDatabasePath(cacheDirPath);
    //设置  Application Caches 缓存目录
    webview.getSettings().setAppCachePath(cacheDirPath);
    //开启 Application Caches 功能
    webview.getSettings().setAppCacheEnabled(true);

    webview.getSettings().setUserAgentString(webview.getSettings().getUserAgentString() + Constants.MADREAIN_UA_EXTRA);
  }

代码示例来源:origin: stackoverflow.com

final WebSettings  settings = wv_payment.getSettings();
   settings.setJavaScriptEnabled(true);
   settings.setDisplayZoomControls(false);
   settings.setAppCacheEnabled(true);
   settings.setLoadsImagesAutomatically(true);
   settings.setBuiltInZoomControls(false);
   settings.setPluginState(WebSettings.PluginState.ON);
   if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
     settings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);

代码示例来源:origin: stackoverflow.com

final WebSettings  settings = easyweb.getSettings();

    settings.setJavaScriptEnabled(true);
    settings.setDisplayZoomControls(false);
    settings.setAppCacheEnabled(true);
    settings.setLoadsImagesAutomatically(true);
    settings.setBuiltInZoomControls(false);
    settings.setPluginState(WebSettings.PluginState.ON);

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
      settings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);

easyweb.loadUrl("http://www.doriddles.com/Riddles/Easy");

代码示例来源:origin: wutq/AndroidModuleDemo

getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);

代码示例来源:origin: calvinaquino/LNReader-Android

private void init(Context context) {
  if (!isInEditMode()) {
    setWebViewClient(new MyWebViewClient((Activity) context));
    // Create our ScaleGestureDetector
    mScaleDetector = new ScaleGestureDetector(context, new ScaleListener());
    // fake user agent to mobile
    String userAgent = this.getSettings().getUserAgentString();
    if (!userAgent.contains("Mobile")) {
      if (userAgent.contains("Safari")) {
        userAgent = userAgent.replace("Safari", "Mobile Safari");
      } else {
        userAgent = userAgent + " Mobile Safari/537.16";
      }
      this.getSettings().setUserAgentString(userAgent);
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
      // allow to open local file even in https mode.
      this.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
    }
  }
}

代码示例来源:origin: wzmyyj/ZYMK

public void initWeb() {
//        web.clearCache(true);
//        web.clearHistory();
    web.requestFocus();
    WebSettings webSettings = web.getSettings();

    webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
    webSettings.setJavaScriptEnabled(true);
    webSettings.setSupportZoom(true);
    webSettings.setBuiltInZoomControls(true);
    webSettings.setBlockNetworkImage(false);
    webSettings.setDomStorageEnabled(true);
    webSettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);

    webSettings.setDomStorageEnabled(true);
    webSettings.setAllowFileAccess(true);
    webSettings.setAppCacheEnabled(true);
    webSettings.setUseWideViewPort(true);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
      webSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
    }
  }

代码示例来源:origin: 24Kshign/SuspensionWindow

@SuppressLint("SetJavaScriptEnabled")
private void initWebViewSetting() {
  mWebView.setVerticalScrollBarEnabled(false);
  mWebView.setHorizontalScrollBarEnabled(false);
  WebSettings webSetting = mWebView.getSettings();
  webSetting.setJavaScriptEnabled(true);
  webSetting.setAllowFileAccess(true);
  webSetting.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
  webSetting.setSupportZoom(false);
  webSetting.setBuiltInZoomControls(false);
  webSetting.setUseWideViewPort(true);
  webSetting.setSupportMultipleWindows(false);
  webSetting.setLoadWithOverviewMode(true);
  webSetting.setAppCacheEnabled(true);
  webSetting.setDatabaseEnabled(true);
  webSetting.setGeolocationEnabled(true);
  webSetting.setDomStorageEnabled(true);
  webSetting.setAppCacheMaxSize(Long.MAX_VALUE);
  webSetting.setAppCachePath(getDir("appCache", Context.MODE_PRIVATE).getPath());
  webSetting.setDatabasePath(getDir("databases", Context.MODE_PRIVATE).getPath());
  webSetting.setGeolocationDatabasePath(getDir("geolocation", Context.MODE_PRIVATE).getPath());
  webSetting.setPluginState(WebSettings.PluginState.ON);
  webSetting.setRenderPriority(WebSettings.RenderPriority.HIGH);
  webSetting.setTextSize(WebSettings.TextSize.NORMAL);
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    webSetting.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
  }
  mWebView.loadUrl(mUrl);
}

代码示例来源:origin: AlarmZeng/BaseProject

ws.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);

代码示例来源:origin: mengzhidaren/RecylerViewMultiHeaderView

private void setWebSeting() {
  WebSettings settings = webView.getSettings();
  settings.setDefaultTextEncodingName("UTF-8");
  settings.setSupportZoom(false);
  settings.setDisplayZoomControls(false);
  settings.setJavaScriptEnabled(true);
  settings.setBlockNetworkImage(true);
  settings.setCacheMode(WebSettings.LOAD_NO_CACHE);
  settings.setAppCacheEnabled(false);
  settings.setSaveFormData(false);
  // 自适应屏幕
  settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    settings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
  }
  webView.setWebViewClient(new MyWebViewClient());
}

代码示例来源:origin: mengzhidaren/RecylerViewMultiHeaderView

settings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);

相关文章

微信公众号

最新文章

更多

WebSettings类方法