Android WebView VS 手机浏览器

发布于 2024-12-04 02:42:58 字数 1111 浏览 0 评论 0原文

我在 Android 中使用 WebView 时经历了很多奇怪的行为,我想知道为什么 WebView 和每部手机上安装的浏览器

例如,我开发了一些必须显示 HTML 内容的应用程序,其中包含 jquery-mobileflashjavascript、YouTube 嵌入等。因此,我在 WebViews 中显示此页面时遇到了很多问题。它们要么根本不会显示,只是空白,要么视频无法播放等等。奇怪的是,如果在手机上安装的浏览器中打开它们,它们可以正常工作。我启用了 JavaScript,我尝试了不同的 WebSettings,我设置了 WebChromeClient 和<一href="http://developer.android.com/reference/android/webkit/WebViewClient.html" rel="noreferrer">WebViewClient 寻找 javascript 错误...但什么也没有工作了。

所以我得出的结论是,WebView 组件与手机上安装的 Browser 应用程序完全不同。我认为每个制造商都会制作自己的浏览器来支持尽可能多的页面,而WebView仍然是标准浏览器,包含在Android SDK<中/代码>。

我说得对吗?或者还有其他原因/解释? 谢谢。

编辑: @ondoteam 建议的所有内容均已启用并设置。我不再有对该网站的引用,无论如何,这些网站都是内部的。

I've experienced a LOT of strange behaviours with using WebView in Android and I'm wondering why there are so many diffrences between the WebView and the Browserinstalled on each phone?

As an example, I've developed some applications that had to display HTML content, which contained either jquery-mobile, flash,javascript, YouTube embedded and so on. So I had a lot of problems with displaying this pages inside WebViews. Either they wouldn't get displayed at all, just blank, either the videos won't play and so on. And the strange thing is that they work properly if opened in the Browser installed on the phone. I had JavaScript enabled, I tried diffrent WebSettings, I had set the WebChromeClient and WebViewClient looking for javascript errors... but nothing worked.

So I got to the conclusion that the WebView component is completely different from the Browser application installed on the phones. I'm thinking that every manufacturer makes their own Browser to support as many as possible pages, and the WebView remains the standard one, included in the Android SDK.

Am I right? Or there is another reasons/explanation for this?
Thanks.

EDIT: Everything that @ondoteam has suggested was enabled and set at the time being. I no longer have the references to that websites, which anyway were internal.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

绝對不後悔。 2024-12-11 02:42:58

本文概述了您对制造商之间的库存浏览器差异的猜测,这绝对是正确的:每个团队在工作前需要进行 5 次现实检查在 Android webkit 上

...这确实会带来麻烦并且神秘/难以诊断/解决问题。

至于您的 WebView 实现问题:

jquery-mobile 的版本可能是一个问题jquery-mobile 加载到 android WebView 如果您使用的是 jquery.mobile-1.0.1.min.js 您可能想尝试未压缩的 jquery.mobile-1.0.1.js

和 Flash :-/ 祝你好运:
使用带有 Flash 的 Web 视图时屏幕闪烁

WebView 中的 Flash 无法在 Android 3.2 上运行

Flash 视频未在 Android 3.0.1 的 WebView 中显示< /a>

对于加载 SWF:

将 SWF 加载到 WebView

在 android 中加载 flash 文件 (.swf) webview

祝你好运,似乎与设备、Android 版本等有很多变量。并且需要坚持尝试/错误。

This article outlines your speculation about stock browser differences between manufacturers, that absolutely is true: 5 reality checks every team needs before working on Android webkit

...which does cause trouble and mysterious/difficult to diagnose/solve problems.

As far as your issues with your WebView implementation:

Version of jquery-mobile may be an issue jquery-mobile loaded into an android WebView if you are using jquery.mobile-1.0.1.min.js you may want to try the uncompressed jquery.mobile-1.0.1.js

And Flash :-/ Good luck:
Screen blinking when using a webview with flash

Flash in WebView not working on Android 3.2

Flash video not displaying in WebView for Android 3.0.1

For loading SWF:

Load an SWF into a WebView

loading flash files (.swf) webview in android

Good luck with that, seems like a lot of variables with devices, Android versions, etc. And will take persistence with trial/error.

毁梦 2024-12-11 02:42:58

股票浏览器和 WebView 不同。使用所有调整,

    WebView browser;

    browser.clearFormData();
    browser.clearHistory();
    browser.clearCache(true);

    browser.getSettings().setAppCacheEnabled(true);
    browser.getSettings().setDatabaseEnabled(true);
    browser.getSettings().setDomStorageEnabled(true);
    browser.setWebChromeClient(new WebChromeClient());

仍然无法正确加载高分辨率图像,而 Android 浏览器可以很好地加载这些图像。
只有部分图像可以在 webview 屏幕上看到,该屏幕完全显示在普通 Android 浏览器上。
最新的 Android 4X SDK 中也观察到了此行为。
这意味着 Android 默认浏览器会显着调整 webkit/webview 代码以显示任何 url

The stock browser and WebView differs .Using all the tweaks like

    WebView browser;

    browser.clearFormData();
    browser.clearHistory();
    browser.clearCache(true);

    browser.getSettings().setAppCacheEnabled(true);
    browser.getSettings().setDatabaseEnabled(true);
    browser.getSettings().setDomStorageEnabled(true);
    browser.setWebChromeClient(new WebChromeClient());

still it does not load high resolution images properly which is being loaded perfectly well by the android browser.
Only part of the image can be visible on the webview screen which appears fully on normal android browser.
This behavior is observed with latest Android 4X SDK as well.
Which means android default browser significantly tweaks the webkit/webview code to show any url

再见回来 2024-12-11 02:42:58

WebView 默认情况下受到限制。您应该致电 setWebChromeClient 和家人以获得良好的浏览体验。此外,不要忘记 setJavaScriptEnabled() 和其他类似的东西。抱歉我的简短...我认为您不需要示例。

http://developer.android.com/reference/android/webkit/WebView.html

WebView by default is restricted. You should call setWebChromeClient and family to have a decent browsing experience. In addition, don't forget setJavaScriptEnabled() and other similar stuff. Sorry for my brevity... I think that you don't need examples.

http://developer.android.com/reference/android/webkit/WebView.html

入怼 2024-12-11 02:42:58

您检查过这个问题吗:jquery-mobile 加载到 android WebView

可能是您使用了错误的库。无论如何,请检查一下。

have you checked this question : jquery-mobile loaded into an android WebView

it might be that you're using the wrong libraries. Just check in any case.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文