android.webkit.WebView.setWebChromeClient()方法的使用及代码示例

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

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

WebView.setWebChromeClient介绍

暂无

代码示例

代码示例来源:origin: RobotiumTech/robotium

public void run() {
    webView.getSettings().setJavaScriptEnabled(true);
    webView.setWebChromeClient(robotiumWebClient);
  }
});

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

WebView vistaWeb = (WebView) findViewById(R.id.webview);
vistaWeb.setWebChromeClient(new MyCustomChromeClient(this));
vistaWeb.setWebViewClient(new MyCustomWebViewClient(this));
vistaWeb.clearCache(true);
vistaWeb.clearHistory();
vistaWeb.getSettings().setJavaScriptEnabled(true);
vistaWeb.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);

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

getWindow().requestFeature(Window.FEATURE_PROGRESS);

WebView mWebView = (WebView) findViewById(R.id.mywebview);

mWebView.getSettings().setJavaScriptEnabled(true);

final Activity activity = this;

mWebView.setWebChromeClient(new WebChromeClient(){

     public void onProgressChanged(WebView view, int progress) {
         activity.setTitle("Loading...");
         activity.setProgress(progress * 100);
          if(progress == 100)
            activity.setTitle("My title");
         }
});

mWebView.loadUrl(URL);

代码示例来源:origin: jaydenxiao2016/AndroidFire

private void setWebView() {
  webView.loadUrl(getIntent().getStringExtra(AppConstant.NEWS_LINK));
  webView.setWebViewClient(new WebViewClient() {
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
      if (url != null) view.loadUrl(url);
      return true;
    }
  });
  webView.setWebChromeClient(new WebChromeClient() {
    @Override
    public void onProgressChanged(WebView view, int newProgress) {
      super.onProgressChanged(view, newProgress);
      if (newProgress == 100) {
        progressBar.setVisibility(View.GONE);
      } else {
        progressBar.setVisibility(View.VISIBLE);
        progressBar.setProgress(newProgress);
      }
    }
  });
}

代码示例来源:origin: xinghongfei/LookLook

private void initView() {
  mToolbar.setTitleMargin(20,20,0,10);
  mToolbar.setNavigationIcon(R.drawable.ic_arrow_back);
  mToolbar.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
      mNest.smoothScrollTo(0,0);
    }
  });
  mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
      expandImageAndFinish();
    }
  });
  mTranslateYTextView.setText(title);
  WebSettings settings = wvZhihu.getSettings();
  settings.setJavaScriptEnabled(true);
  settings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
  settings.setLoadWithOverviewMode(true);
  settings.setBuiltInZoomControls(true);
  //settings.setUseWideViewPort(true);造成文字太小
  settings.setDomStorageEnabled(true);
  settings.setDatabaseEnabled(true);
  settings.setAppCachePath(getCacheDir().getAbsolutePath() + "/webViewCache");
  settings.setAppCacheEnabled(true);
  settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
  wvZhihu.setWebChromeClient(new WebChromeClient());
}

代码示例来源:origin: ankidroid/Anki-Android

private void destroyWebView(WebView webView) {
  if (webView != null) {
    webView.stopLoading();
    webView.setWebChromeClient(null);
    webView.setWebViewClient(null);
    webView.destroy();
  }
}

代码示例来源:origin: ankidroid/Anki-Android

webView.setWebChromeClient(new WebChromeClient() {
  public void onProgressChanged(WebView view, int progress) {
    webView.loadUrl("file:///android_asset/changelog.html");
    break;

代码示例来源:origin: robolectric/robolectric

@Test
public void shouldRecordWebChromeClient() {
 WebChromeClient webChromeClient = new WebChromeClient();
 assertThat(shadowOf(webView).getWebChromeClient()).isNull();
 webView.setWebChromeClient(webChromeClient);
 assertThat(shadowOf(webView).getWebChromeClient()).isSameAs(webChromeClient);
}

代码示例来源:origin: TommyLemon/APIJSON

public void initData() {
  WebSettings webSettings = wvWebView.getSettings();
  webSettings.setJavaScriptEnabled(true);
  wvWebView.setWebChromeClient(new WebChromeClient() {  
    @Override  
    public void onReceivedTitle(WebView view, String title) {  
  wvWebView.setWebViewClient(new WebViewClient(){
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url){
  wvWebView.loadUrl(url);

代码示例来源:origin: nanchen2251/RxJava2Examples

@SuppressLint("SetJavaScriptEnabled")
@Override
public void initWebView() {
  WebSettings settings = mWebView.getSettings();
  settings.setLoadWithOverviewMode(true);
  settings.setJavaScriptEnabled(true);
  settings.setAppCacheEnabled(true);
  settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
  settings.setSupportZoom(true);
  mWebView.setWebChromeClient(new MyWebChrome());
  mWebView.setWebViewClient(new MyWebClient());
}

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

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: stackoverflow.com

WebView webView = (WebView) findViewById(R.id.webview);

WebSettings webSettings = webView.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setDomStorageEnabled(true);
webView.setWebChromeClient(new WebChromeClient());

try {
  String html = readAssetFile("www/index.html");
  webView.loadDataWithBaseURL("file:///android_asset/www/", html, "text/html", "UTF-8", null);
} catch (IOException e) {
}

代码示例来源:origin: bingoogolapple/BGASwipeBackLayout-Android

@Override
protected void setListener() {
  mRefreshLayout.setDelegate(this);
  mContentWv.setWebViewClient(new WebViewClient() {
    @Override
    public void onPageFinished(WebView view, String url) {
      mRefreshLayout.endRefreshing();
    }
  });
  mContentWv.setWebChromeClient(new WebChromeClient() {
    @Override
    public void onProgressChanged(WebView view, int newProgress) {
      if (newProgress == 100) {
        mProgressBar.setVisibility(View.GONE);
      } else {
        if (mProgressBar.getVisibility() == View.GONE) {
          mProgressBar.setVisibility(View.VISIBLE);
        }
        mProgressBar.setProgress(newProgress);
      }
    }
  });
  findViewById(R.id.transparent).setOnClickListener(this);
  findViewById(R.id.not_transparent).setOnClickListener(this);
  findViewById(R.id.to_transparent).setOnClickListener(this);
}

代码示例来源:origin: hidroh/materialistic

if (isUrl(text)) {
  WebView webView = new WebView(this);
  webView.setWebChromeClient(new WebChromeClient() {
    @Override
    public void onReceivedTitle(WebView view, String title) {
  webView.loadUrl(text);
} else if (!TextUtils.isEmpty(text)) {
  extractUrl(text);

代码示例来源:origin: airbnb/AirMapView

@SuppressLint({ "SetJavaScriptEnabled", "AddJavascriptInterface" })
@Override public View onCreateView(
  LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
 View view = inflater.inflate(R.layout.fragment_webview, container, false);
 webView = (WebView) view.findViewById(R.id.webview);
 mLayout = (ViewGroup) view;
 WebSettings webViewSettings = webView.getSettings();
 webViewSettings.setSupportZoom(true);
 webViewSettings.setBuiltInZoomControls(false);
 webViewSettings.setJavaScriptEnabled(true);
 webViewSettings.setGeolocationEnabled(true);
 webViewSettings.setAllowFileAccess(false);
 webViewSettings.setAllowContentAccess(false);
 webView.setWebChromeClient(new GeoWebChromeClient());
 AirMapType mapType = AirMapType.fromBundle(getArguments());
 webView.loadDataWithBaseURL(mapType.getDomain(), mapType.getMapData(getResources()),
   "text/html", "base64", null);
 webView.addJavascriptInterface(new MapsJavaScriptInterface(), "AirMapView");
 return view;
}

代码示例来源:origin: TommyLemon/Android-ZBLibrary

public void initData() {
  WebSettings webSettings = wvWebView.getSettings();
  webSettings.setJavaScriptEnabled(true);
  wvWebView.setWebChromeClient(new WebChromeClient() {
    @Override
    public void onReceivedTitle(WebView view, String title) {
  wvWebView.setWebViewClient(new WebViewClient(){
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url){
  wvWebView.loadUrl(url);

代码示例来源:origin: smuyyh/BookReader

private void initVweView() {
  mProgressBar.setMax(100);
  mWebView.getSettings().setJavaScriptEnabled(true);
  mWebView.setWebChromeClient(new WebChromeClient() {
    @Override
    public void onProgressChanged(WebView view, int newProgress) {
  mWebView.setWebViewClient(new WebViewClient() {
    @Override
    public void onPageStarted(WebView view, String url, Bitmap favicon) {
  mWebView.getSettings().setBuiltInZoomControls(true);
  mWebView.getSettings().setDisplayZoomControls(false);
  mWebView.getSettings().setUseWideViewPort(true);
  mWebView.getSettings().setLoadWithOverviewMode(true);

代码示例来源:origin: kaku2015/ColorfulNews

private void setWebView() {
  mWebView.loadUrl(getIntent().getStringExtra(Constants.NEWS_LINK));
  mWebView.setWebViewClient(new WebViewClient() {
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
      if (url != null) view.loadUrl(url);
      return true;
    }
  });
  mWebView.setWebChromeClient(new WebChromeClient() {
    @Override
    public void onProgressChanged(WebView view, int newProgress) {
      super.onProgressChanged(view, newProgress);
      if (newProgress == 100) {
        mProgressBar.setVisibility(View.GONE);
      } else {
        mProgressBar.setVisibility(View.VISIBLE);
        mProgressBar.setProgress(newProgress);
      }
    }
  });
}

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

final WebView containerWbVw = findViewById(R.id.fragment_wbVw_container_id);
WebSettings webSettings = containerWbVw.getSettings();
webSettings.setJavaScriptEnabled(true);
containerWbVw.setWebChromeClient(new WebChromeClient());

代码示例来源:origin: sunfusheng/GlideImageView

private void initListener() {
  webView.setWebViewClient(new WebViewClient() {
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
  webView.setWebChromeClient(new WebChromeClient() {
    @Override
    public void onProgressChanged(WebView view, int newProgress) {

相关文章

WebView类方法