首页 > 解决方案 > 中国安卓设备。WebView 使用什么浏览器?

问题描述

中国默认不允许在中国安卓设备上安装谷歌Chrome浏览器,我们也不能要求使用它进行测试。我们注意到我们的 Hybrid 应用程序在中国设备上出现问题

在装有 Android 5+ 的中国设备中。

1.- WebView 组件与标准不同吗?

2.- WebView 使用什么渲染引擎和javascript引擎?WebKit 和 V8?

3.- 哪个中文浏览器的行为与 WebView/Chrome 最相似?

谢谢。

标签: androidgoogle-chromeandroid-webview

解决方案


多年来,我一直在使用中国 Android 设备。我的许多客户都拥有 ONDA 和 CUBE 平板设备,有时运行的版本可能与 4.2.2 一样旧,而且大多是 5.0+。这是一个很难的问题,因为有这么多的口味,当然他们没有谷歌播放服务。大多数这些设备上的 WebView 组件运行良好。渲染引擎似乎是 WebGL。以下是一些屏幕截图,显示了我使用的 ONDA 7" 平板电脑的浏览器详细信息。 在此处输入图像描述 这是我刚刚在我的一个 ONDA 7" 平板电脑上测试的代码,它运行良好

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

//Scroll bars should not be hidden
webView.setScrollbarFadingEnabled(false);
webView.setHorizontalScrollBarEnabled(true);
webView.setVerticalScrollBarEnabled(true);
webView.setFitsSystemWindows(true);

//Enable JavaScript
webView.getSettings().setJavaScriptEnabled(true);

//Set the user agent
webView.getSettings().setUserAgentString("AndroidWebView");

//Clear the cache
webView.clearCache(true);
webView.setBackgroundColor(Color.parseColor("#FFFFFF"));
webView.setFadingEdgeLength(10);
webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setDisplayZoomControls(false);

final Activity activity = this;
final ProgressDialog progressDialog = new ProgressDialog(activity);
//progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
progressDialog.setProgressStyle(ProgressDialog.THEME_HOLO_LIGHT);
progressDialog.setCancelable(true);

webView.setWebChromeClient(new WebChromeClient() {
    public void onProgressChanged(WebView view, int progress) {
        progressDialog.setCanceledOnTouchOutside(true);
        progressDialog.setTitle("Loading visualization ...");
        progressDialog.setButton("Cancel", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                webView.destroy();
                finish();
            } });
        progressDialog.show();
        progressDialog.setProgress(0);
        activity.setProgress(progress * 1000);
        progressDialog.incrementProgressBy(progress);
        if(progress == 100 && progressDialog.isShowing())
            progressDialog.dismiss();
    }
});

// Load the URL of the HTML file containing the JavaScript D3 code
webView.loadUrl("https://www.google.com");

推荐阅读