日期:2014-05-16  浏览次数:20612 次

基于HTML5技术的电力3D监控应用(三)

继(一)和(二)之后不少,不少网友问移动终端的使用问题,因为我们项目这次采用Android平板终端,所以我对这方面有点肤浅的研究,这篇分享些项目经验总结,希望对大家有所帮助。

?

电力3D项目去年底立项时仅仅是PC浏览器的3D展示要求,后来慢慢增加了要求也能在平板上运行,因为我们的系统大部分是内网的,不可能要求移动终端得上app store去下载应用程序,虽然apple也提供企业内部发布的解决方案,但还是远不如android安装app方便,对于企业应用三天两头就需要改动需求,我们的发布非常频繁,所以最终移动端选型采用Android的方案。

?

还好Google挺给力今年初提供了Android浏览器WebGL的解决方案:Google finally makes it easy to enable WebGL support in latest Chrome for Android?当然如今哪怕没有Chrome,Firefox和Opera等众多移动浏览器也都支持WebGL了,而且Firefox和Opera都不需要设置开启WebGL开关了,而且手机上的Chrome还得通过在URL输入chrome:flags,然后开启Enable WebGL才可以


?

手机我用的Nexus 5测试的,而平板我用Nexus 7第二代测试的,Nexus 7到手感觉还是很轻很好用,预装的操作系统还不是最新的,不过已经可以升级到Android 4.4.2 (KitKat)版本了,我更新了Chrome Android31速度还是明显很快速。

?

Nexus手机直接可以传送文件,平板则需要安装Android File Transfer软件,这没什么最让我震惊的是在这里,我调试时发现平板上没有“Developer options”选型了,没有这个选型我就没法用通过PC进行USB Debugging了,查了半天资料How to enable developer settings on Android 4.2,居然通过点击“Build number”的栏目七次才会出现,Google这些工程师真是Geek啊。

Here's how to get them back:

  1. Go to the settings menu, and scroll down to "About phone." Tap it.
  2. Scroll down to the bottom again, where you see "Build number." (Your build number may vary from ours here.)
  3. Tap it seven (7) times. After the third tap, you'll see a playful dialog that says you're four taps away from being a developer. (If only it were that simple, eh?) Keep on tapping, and *poof*, you've got the developer settings back.

最开始我们也考虑过用WebView打包apk的方式,但遇到了不少麻烦大部分WebView和独立安装的Chrome app并不贡献内核,google走了两条路,WebView有套自己的WebKit版本,外面的Chrome app走自己的WebKit版本,而且WebView的版本不用说肯定是相当古老的,因此别说WebGL连Canvas的支持我们都遇到很多坑,这方面还好引擎已经帮我们绕开了很多坑。

?

当然Google不会止步不前,最新的KitKat已经将WebView升级到了Chrome for Android的30版本,这个版本的HTML5功能对大部分应用来说也算足够了 ,当然后续WebView要是也能自动升级就好了,这个还得等...

What version of Chrome is it based on?

The WebView shipped with Android 4.4 (KitKat) is based on the same code as Chrome for Android version 30. The WebView does not have full feature parity with Chrome for Android and is currently given the version number 30.0.0.0.

Will the new WebView auto-update?

Evergreen browsers (like Chrome and Firefox) auto-update and keep their users up to date so the