一种“一次开发,不同手机平台都能运行”的应用开发方案

来源:互联网 发布:淘宝伊人靓妆假货 编辑:程序博客网 时间:2024/05/16 15:30

一种“一次开发,不同手机平台都能运行”的应用开发方案


目标

代码只写一遍,打包后起码在iphone和android上都能运行。


编程语言

当然用html+Js+css

你可能会问“web脚本不能调用手机本地api啊,怎么办?”,答案是用phonegap。很简单,看看http://www.phonegap.cn/的介绍吧,phonegap已经支持了很多本地api的调用,如手机震动、gps、媒体录音等等。

你还会质疑“web脚本的体验能赶上native的原生应用嘛”,别担心,有senche呢,这个东东,牛逼的很。去www.sencha.com看看吧。用它做出来的东西,界面体验几乎能与原生应用的界面媲美了。


如虎添翼

webapp在与服务器的通信方面,是基于http,长期以来一直无法实现稳定和实时的双向通信,但是最近随着html5的出现,这个问题也会解决了,快到www.websockets.org上看看吧,有了websocket的支持,使webapp如虎添翼啊。


不要最快只要更快

最后,你是不是还担心web脚本写的应用,会带来性能问题,那么看看android 官网上google给出的方案:

Avoid multiple file requests
Because mobile devices typically have a connection speed far slower than a desktop computer, you should make your web pages load as fast as possible. One way to speed it up is to avoid loading extra files such as stylesheets and script files in the <head>. Instead, provide your CSS and JavaScript directly in the <head> (or at the end of the <body>, for scripts that you don't need until the page is loaded). Alternatively, you should optimize the size and speed of your files by compressing them with tools like Minify.

用了Minify后,用YSlow 和 Monster评测一下,看看是不是性能有提高呢!!










原创粉丝点击