com.tencent.smtt.sdk.WebView类的使用及代码示例

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

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

WebView介绍

暂无

代码示例

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

public static final void clearWebView(WebView m) {
  if (m == null)
    return;
  if (Looper.myLooper() != Looper.getMainLooper())
    return;
  m.loadUrl("about:blank");
  m.stopLoading();
  if (m.getHandler() != null)
    m.getHandler().removeCallbacksAndMessages(null);
  m.removeAllViews();
  /*ViewGroup mViewGroup = null;
  if ((mViewGroup = ((ViewGroup) m.getParent())) != null)
    mViewGroup.removeView(m);*/
  m.setWebChromeClient(null);
  m.setWebViewClient(null);
  m.setTag(null);
  m.clearHistory();
  m.destroy();
  m = null;
}

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

@Override
public boolean back() {
  if(this.mEventInterceptor!=null&&this.mEventInterceptor.event()){
    return true;
  }
  if(mWebView!=null&&mWebView.canGoBack()){
    mWebView.goBack();
    return true;
  }
  return false;
}

代码示例来源:origin: leftcoding/GankLy

@Override
  protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
//        boolean ret = super.drawChild(canvas, child, drawingTime);
//        canvas.save();
//        Paint paint = new Paint();
//        paint.setColor(0x7fff0000);
//        paint.setTextSize(24.f);
//        paint.setAntiAlias(true);
//        if (getX5WebViewExtension() != null) {
//            canvas.drawText(this.getContext().getPackageName() + "-pid:"
//                    + android.os.Process.myPid(), 10, 50, paint);
//            canvas.drawText(
//                    "X5  Core:" + QbSdk.getTbsVersion(this.getContext()), 10,
//                    100, paint);
//        } else {
//            canvas.drawText(this.getContext().getPackageName() + "-pid:"
//                    + android.os.Process.myPid(), 10, 50, paint);
//            canvas.drawText("Sys Core", 10, 100, paint);
//        }
//        canvas.drawText(Build.MANUFACTURER, 10, 150, paint);
//        canvas.drawText(Build.MODEL, 10, 200, paint);
//        canvas.restore();
//        return ret;
    return super.drawChild(canvas, child, drawingTime);
  }

代码示例来源:origin: leftcoding/GankLy

@Override
  public void onNext(String s) {
    if (TextUtils.isEmpty(s)) {
      mWebView.loadUrl(mUrl);
    } else {
      mWebView.loadDataWithBaseURL(getLoadDataBaseUrl(), s, "text/html", "utf-8", mUrl);
    }
  }
});

代码示例来源:origin: lshAndroid/WebviewTBS

private void loadWebvieUrl(String url) {
  progressBar = (ProgressBar) findViewById(R.id.progressBar);
  webView = (com.tencent.smtt.sdk.WebView) findViewById(R.id.webview_wechat);
  WebSettings webSettings = webView.getSettings();
  webSettings.setJavaScriptEnabled(true);
  webView.loadUrl(url);
  webView.setWebViewClient(new WebViewClient() {
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
  webView.setWebChromeClient(new WebChromeClient() {
    @Override
    public void onProgressChanged(WebView view, int newProgress) {

代码示例来源:origin: leftcoding/GankLy

@SuppressLint("SetJavaScriptEnabled")
@Override
protected void initViews() {
  mWebView = new WebView(this, null);
  mViewParent.addView(mWebView, new FrameLayout.LayoutParams(
      FrameLayout.LayoutParams.MATCH_PARENT,
      FrameLayout.LayoutParams.MATCH_PARENT));
  WebSettings settings = mWebView.getSettings();
  mWebView.requestFocusFromTouch(); //支持获取手势焦点,输入用户名、密码或其他
  settings.setJavaScriptEnabled(true);  //支持js
  settings.setDomStorageEnabled(true); //
  settings.setSupportZoom(true); //设置支持缩放
  settings.setBuiltInZoomControls(true); //
  settings.setDisplayZoomControls(false);//是否显示缩放控件
  settings.setUseWideViewPort(true);  //将图片调整到适合webview的大小
  settings.setLoadWithOverviewMode(true); // 缩放至屏幕的大小
  settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN); //支持内容重新布局
  settings.supportMultipleWindows();  //多窗口
  settings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);  //关闭webview中缓存
  settings.setAllowFileAccess(true);  //设置可以访问文件
  settings.setNeedInitialFocus(true); //当webview调用requestFocus时为webview设置节点
  settings.setJavaScriptCanOpenWindowsAutomatically(true); //支持通过JS打开新窗口
  settings.setLoadsImagesAutomatically(true);  //支持自动加载图片
  settings.setDefaultTextEncodingName("utf-8");//设置编码格式
  mWebView.setWebViewClient(new MyWebViewClient());
  mWebView.setWebChromeClient(new MyWebChromeClient());
}

代码示例来源:origin: lionoggo/FastApp

@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
  view.loadUrl(url);
  return false;
}

代码示例来源:origin: gaolhjy/enjoyshop

private void initData() {
  final WebSettings webSettings = mWebView.getSettings();
  webSettings.setJavaScriptEnabled(true);
  webSettings.setBlockNetworkImage(false);
  webSettings.setAppCacheEnabled(true);
  mWebView.loadUrl(HttpContants.WARES_DETAIL);
  mAppInterfce = new WebAppInterface(this);
  mWebView.addJavascriptInterface(mAppInterfce, "appInterface");
  mWebView.setWebViewClient(new WebViewClient() {
    @Override
    public boolean shouldOverrideUrlLoading(WebView webView, String s) {
      webView.loadUrl(s);
      return true;
    }
    @Override
    public void onPageFinished(WebView webView, String s) {
      super.onPageFinished(webView, s);
      //整个页面加载完后,才能调用这个方法
      mAppInterfce.showDetail();
    }
  });
}

代码示例来源:origin: CN-ZPH/Three360panorama

@SuppressLint("SetJavaScriptEnabled")
  private void initView() {
    tencent_webview = (WebView) findViewById(R.id.web);
    tencent_webview.loadUrl(url);
    WebSettings webSettings = tencent_webview.getSettings();
    webSettings.setJavaScriptEnabled(true);
    tencent_webview.setWebViewClient(new WebViewClient() {
      @Override
      public boolean shouldOverrideUrlLoading(WebView view, String url) {
        return true;
      }
    });
  }
}

代码示例来源:origin: dom4j1/Red

WebSettings webSetting = mWebView.getSettings();
webSetting.setBlockNetworkImage(false); //允许WebView从网络上加载图片
webSetting.setAppCacheEnabled(true); //启用应用缓存
mWebView.setWebViewClient(new WebViewClient() {
  @Override
  public boolean shouldOverrideUrlLoading(WebView view, String url) {

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

@Override
public WebListenerManager setWebViewClient(WebView webView, WebViewClient webViewClient) {
  webView.setWebViewClient(webViewClient);
  return this;
}

代码示例来源:origin: gaolhjy/enjoyshop

@Override
  protected void onDestroy() {
    super.onDestroy();
    if (mWebView != null) {
      mWebView.destroy();
    }
  }
}

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

this.mWebSettings = webView.getSettings();
mWebSettings.setBuiltInZoomControls(false);
mWebSettings.setSavePassword(false);
if (AgentWebX5Utils.checkNetwork(webView.getContext())) {
String dir = AgentWebX5Config.getCachePath(webView.getContext());
Log.i("Info","dir:"+dir+"   appcache:"+ AgentWebX5Config.getCachePath(webView.getContext()));

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

@Override
public WebListenerManager setWebChromeClient(WebView webview, WebChromeClient webChromeClient) {
  webview.setWebChromeClient(webChromeClient);
  return this;
}

代码示例来源:origin: dom4j1/Red

String url = intent.getStringExtra(Constants.URL);
WebSettings webSetting = mWebView.getSettings();
webSetting.setBlockNetworkImage(false); //允许WebView从网络上加载图片
webSetting.setAppCacheEnabled(true); //启用应用缓存
mWebView.setWebViewClient(new WebViewClient() {
  @Override
  public boolean shouldOverrideUrlLoading(WebView view, String url) {
mWebView.setWebChromeClient(new WebChromeClient(){
  @Override
  public void onProgressChanged(WebView view, int newProgress) {
mWebView.loadUrl(url);

代码示例来源:origin: leftcoding/GankLy

@SuppressLint("SetJavaScriptEnabled")
@Override
protected void initViews() {
  mWebView = new WebView(this, null);
      FrameLayout.LayoutParams.MATCH_PARENT));
  WebSettings settings = mWebView.getSettings();
  mWebView.requestFocusFromTouch(); //支持获取手势焦点,输入用户名、密码或其他
  settings.setJavaScriptEnabled(true);  //支持js
  settings.setDomStorageEnabled(true); //
  settings.setPluginState(WebSettings.PluginState.ON_DEMAND);
  mWebView.setWebViewClient(new MyWebViewClient());
  mWebView.setWebChromeClient(new MyWebChromeClient());
  mWebView.loadUrl(mUrl);

代码示例来源:origin: lionoggo/Akit-Reader

@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
  view.loadUrl(url);
  return false;
}

代码示例来源:origin: leftcoding/GankLy

@Override
protected void onDestroy() {
  if (mWebView != null) {
    mWebView.destroy();
  }
  super.onDestroy(); // All you have to do is destroy() the WebView before Activity finishes
}

代码示例来源:origin: lionoggo/Akit-Reader

@Override
public void initView(View view) {
  WebSettings settings = webview.getSettings();
  settings.setJavaScriptEnabled(true);
  settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
  webview.setWebViewClient(new WebViewClient() {
  webview.setWebChromeClient(new WebChromeClient() {
    @Override
    public void onProgressChanged(WebView view, int newProgress) {
  webview.loadUrl(url);

代码示例来源:origin: gaolhjy/enjoyshop

@Override
public boolean shouldOverrideUrlLoading(WebView webView, String s) {
  webView.loadUrl(s);
  return true;
}

相关文章