开发跨平台移动应用

越来越多的移动平台正在推出,开发人员可以使用 sdk。有各种各样的流动平台: 安卓,iOS,Moblin,Windows mobile 7,RIM,symbian,bada,maemo 等等。

而跨平台应用的制作则是开发人员头疼的问题。我正在寻找跨平台的共同点,这将有助于开发人员谁想移植应用程序到所有平台。比如什么是 diff 屏幕分辨率,输入方法,打开 gl 支持等等。 请分享您所知道的任何平台的详细信息。

或者有可能通过在 html (小部件类型的东西)中编写代码并将其加载到本机应用程序中。 我知道 android,我们可以通过调用 setContentView(view)将 web 视图添加到应用程序中

请分享类的详细信息,我们可以将 html 视图添加到您所知道的不同类型平台的本机应用程序中。

这个线程的目的是在开发人员之间共享共同的细节。

跨平台工具及库

42195 次浏览

Yes, html5 is getting some attention. You should also look at this consortium & platform to come in Q4. Not sure about the success of that project, as it sounds like a huge challenge, but here are the details:

Website: http://www.wholesaleappcommunity.com/default.aspx

News: http://news.google.de/news/search?aq=f&pz=1&cf=all&ned=us&hl=en&q=%22Wholesale+Applications+Community%22

WAC aims to publish its initial specification and components of its SDK to developers in November. This specification will be based on W3C standards and create a strong platform for developing rich mobile web applications. WAC will also provide backwards compatibility for devices based upon the current JIL and BONDI specifications. (http://www.convergedigest.com/Bandwidth/newnetworksarticle.asp?ID=31021)

.

It IS an international coalition of around 25 telecom companies that's aiming to create a platform open to all developers and selling to all mobile phone users. (http://www.downloadsquad.com/2010/02/15/atandt-wholesale-applications-community-is-a-platform-not-an-app/)

You get some commonality when deploying as a webapp (html5 as mentioned above) but for rich native apps the APIs are completely different for the various smartphones.

HTML5 may improve things somewhat but to do interesting things you need to go native.

There are 'cross platform' smartphone frameworks such as Phonegap but I've heard mostly bad things about using it for "real" work. (lots of overhead etc)

My answer here covers some of the technical limitations of cross-platfrom tools but let me expand a bit:

I think that cross-platform tools have historically always been also-rans because such tools have the wrong philosophical focus.

All the selling points for cross-plaform tools are the benefits they bring to developers. They are sold on the idea that they allow the developers to write-once-run-anywhere. They are sold on the idea that they allow the developers to expand their market without learning new APIs. They are sold on the idea that they allow the developers to slash cost and time to market.

What cross-plaform tool are NOT sold on is the benefit they bring to end users.

Benefit to the end user is not a selling point because cross-platform development is seldom a benefit to the end user. The end user does not care how hard the developer had to work to bring the product to market. Nor do they care how many platforms the app can run on when they they don't use but one platform. They just care if the app does what they need it to on the hardware they need to run it on. Unless they have a specific need to run the app on many different platforms, the fact that it does brings them no value.

Conversely, the inevitable compromises of making a cross-platform API mean that all the apps created by the API will be at best B-grade on every platform. They will never be the best tool to use on each platform.

All this means that in most use cases, cross-platform tools give the end user an inferior product compared to ones made with platform specific APIs. The end user will always have a better choice.

You make money in the long run by giving end users the most useful tools. If you don't philosophically concentrate on making the end user's life easier and more productive, you are pretty much doomed from the outset. End users have lots of choices and if your tool isn't one of the best you won't make it in the market.

You should only use cross-platform tools if you think, "the users will really benefit from running this app on many different platforms." If you start out looking at cross-platform tools solely because they will make your (the developers) life easier, then you have picked them for the wrong reason and they will hurt you more than they will help.

There are several approaches to cross-platform development on mobile devices. Of course they all have limitations. No solution manages to take advantage of all the device's functionalities the way a native application can.

Re-using code

While all mobile OS don't use the same development language and API you can sometimes share some classes or logic tier code.

C++ for example can probably be re-used for an iOS application, for an Android app by using the NDK, for a Symbian app since they are developed in C++, etc.

Some solutions also offer the possibility to write the app in an other language than the one normally used by the device. The most famous (in fact the only one I know) are commercial and based on the Mono project (C# development):

But I'm not sure we can really call this cross-platform development since the re-use of code is limited depending on the device :

  • Windows Phone 7 will not allow native code development (maybe in further updates)
  • AFAIK mono like project do not exist for all platforms (yet?) bada, webOS, maemo, etc.

And the UI part also stays specific to each device.

Web development

A regular answer when asking about cross-platform development for mobiles is web development. We would then need a wrapper, that will use the mobile browser, to make it look and behave like a native application. That is how some of the cross-platform framework that we will see further on work.

The rise of HTML5 brings to web development functionalities that could only be done with a native application like geolocation, off-line application, local storage.

We can found more and more frameworks to develop web application for mobiles with a native look and feel by taking advantage of the latest web standards HTML5, CSS3, Js:

But HTML5 is still very young and implementation may vary from a browser to another. Most default mobile browsers use the WebKit engine (main exception being Windows mobile/phone using Internet Explorer) and even so they don't necessarily support the same functionalities. Local database is still awkward to work with and we can't be sure how it is going to implemented by the different browsers. Moreover, even with HTML5, web development is still very limited compared to a native app. You can't access contacts, camera, accelerometer, etc.

Edit: Earlier this month the W3C have delivered some warnings about the evolution of HTML5: Article from ZDNet

So it will only suit a limited category of applications.

Cross-platform frameworks

And than we have the cross-platform mobile applications frameworks. With which you can presumably develop once and deploy on different platforms. These solutions usually focus on iOS and Android and rely on the WebKit engine. They offer more interaction with the phone functionalities while developing with web technologies. The most well-known are Nitobi PhoneGap, RhoMobile Rhodes, Appcelerator Titanium. But many others are out there and don't all use the same technique like MoSync which translate your code to it's own intermediate language before compiling it for the desired platform.

[ 1 ] Remember that Apple has a special policy about apps written for their platform. They don't seem to be blocking these apps at this date but it is an information that should be taken into account. Edit: Apple has changed this policy since September 9.

As far as I know most of those devices are able to run this:

Java ME - the Most Ubiquitous Application Platform for Mobile Devices

I think this can serve both as good and bad example.