0

我有一个网页内容,它是 html、js 和静态内容(如图像、视频等)的集合。

当我在其他系统的 Web 服务器中托管 Web 内容时。我可以从我的 Android 库存浏览器(使用 HTC One 4.4.2)渲染它们,但不能从 Chrome 浏览器渲染它们。

如果我在本地获取内容并从我的应用程序中的嵌入式 Web 服务器 (NanoHTTPD) 提供它。(这是我的实际用例)我的网页内容中的视频没有呈现。当我尝试在我的 Web 视图中加载与 loadURL 相同的内容时,也会发生同样的问题。所以这似乎不是我如何在我的应用程序中使用 NanoHTTP 服务器并为我的内容提供服务的问题。问题似乎是 Web 视图的配置或呈现,否则从我的系统服务器提供它会起作用。

在我的 Web 视图中,我启用了所有设置。以下是 Web 视图配置的代码。

webView = (WebView) findViewById(R.id.webView);
        progressBar = (ProgressBar) findViewById(R.id.progressBarForWebView);

        WebSettings webViewSettings = webView.getSettings();
        webViewSettings.setJavaScriptEnabled(true);
        webViewSettings.setJavaScriptCanOpenWindowsAutomatically(true);
        webViewSettings.setPluginState(PluginState.ON);
        webViewSettings
                .setUserAgentString("Mozilla/5.0 (Linux; U; Android 4.4.2; en-in; HTC_One_dual_sim Build/KOT49H) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30");
        String userAgentString = webViewSettings.getUserAgentString();
        webView.getSettings().setAllowFileAccess(true);
        webView.setSoundEffectsEnabled(true);
        webView.setWebViewClient(new MyWebViewClient());

甚至将用户代理设置为从股票浏览器接收到的字符串。我从https://developer.chrome.com/multidevice/webview/overview中了解到,从 4.4 开始,Chrome 和 WebView 的渲染引擎是相同的。

由于我的内容不在 Android Chrome 上运行,而是在 Android Stock 浏览器上运行,即使我更改了用户代理,Web 视图是否也不会呈现我的内容?任何其他方式来呈现我的内容?

干杯,索拉夫

4

0 回答 0