Android WebView VS 手机浏览器
我在 Android
中使用 WebView
时经历了很多奇怪的行为,我想知道为什么 WebView
和每部手机上安装的浏览器
?
例如,我开发了一些必须显示 HTML
内容的应用程序,其中包含 jquery-mobile
、flash
、javascript
、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 Browser
installed 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
本文概述了您对制造商之间的库存浏览器差异的猜测,这绝对是正确的:每个团队在工作前需要进行 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 usingjquery.mobile-1.0.1.min.js
you may want to try the uncompressedjquery.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.
股票浏览器和 WebView 不同。使用所有调整,
仍然无法正确加载高分辨率图像,而 Android 浏览器可以很好地加载这些图像。
只有部分图像可以在 webview 屏幕上看到,该屏幕完全显示在普通 Android 浏览器上。
最新的 Android 4X SDK 中也观察到了此行为。
这意味着 Android 默认浏览器会显着调整 webkit/webview 代码以显示任何 url
The stock browser and WebView differs .Using all the tweaks like
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
WebView
默认情况下受到限制。您应该致电setWebChromeClient
和家人以获得良好的浏览体验。此外,不要忘记 setJavaScriptEnabled() 和其他类似的东西。抱歉我的简短...我认为您不需要示例。http://developer.android.com/reference/android/webkit/WebView.html
WebView
by default is restricted. You should callsetWebChromeClient
and family to have a decent browsing experience. In addition, don't forgetsetJavaScriptEnabled()
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
您检查过这个问题吗: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.