You Are Here:

Community: Blogs

Who am I?

robin.jewsbury

Robin is an innovator and entrepreneur. 1st prize winner in the Calling All Innovators competition 2009 in the Internet Innovation category for TechBuzz widget which Robin wrote. He co-founded Mippin.com (then called Mobizines) in 2004 which won Forum Nokia developer of the year for 2006/7. He founded a new startup, Alibro Ltd in Oct 2009, as a vehicle to further EyeMags.com

 

Calendar

« May 2009 »
Mo Tu We Th Fr Sa Su
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
 

Robin Jewsbury's Forum Nokia Blog

Porting Madness - square plug round hole.

robin.jewsbury | 12 May, 2009 16:44

I am amazed as the sudden interest in what's involved porting of applications between different manufacturers smart phones technologies because I really think something is being missed in many cases.   Why would you want to port code between platforms? Why develop the same thing 4 times because down the line you'll have to maintain 4 different code bases?  Why not develop cross platform in a single code base and use wrappers to cope with each platform idiosyncrasies?  So when I say 4 platforms I am saying iPhone, Android, Blackberry and S60 (we'll leave Microsoft out for the moment but it would fit in this list at some stage).

This reminds me of a situation I was in a few years ago when we were developing an application which worked on a majority of phones.  We had 12 variants of the J2ME version and 2 Symbian variants too.  It ended up with 3 major code bases and with the Java one being divided into the 12 variants.  It was a nightmare to deal with in terms of development, maintenance and testing. 

So when would I recommend actual porting between technologies. Only in 2 circumstances:

1) When code has already been written in an existing technology (ie converting a legacy application)
2) When a display rate of greater than 2 frames per second is required (eg for fast moving games)
 

As developers we strive to write code only once for all platforms. This not only has the advantage of only having to write core code the first time but most importantly that the code is fully maintainable in a single code base. J2ME used to promise this capability, but the iPhone has completely destroyed this. So until recently the fragmentation of technologies in the different devices has made this impossible but the emergence of using web technologies with javascript and css has now made this a reality.

For all other cases I would recommend every developer consider web technologies for creating cross platform applications.

So how can this be achieved with the diverse platforms we have. This is how its done...

For iPhone use a native objective-c wrapper to host the web application which can have local and remote html, javascript and css. The best native wrapper to achieve this is using a project called PhoneGap (www.phonegap.com).

For Android use a native Java wrapper to host the same local/remote web application. Again use the android version of PhoneGap to accomplish this.

For S60 Ed5 touch phones use WRT again with the same local/remote web application. In this case to cope with a remote component Ajax or an iframe can be used.

For S60 non touch phones use WRT too but be aware that iframes do not currently work properly and additionally code for handling keyboard events needs to be added.

For Blackberry the situation is very fluid as the current technology does not work properly, but this is supposed to be fixed very soon and at this stage again I would recommend using Blackberry PhoneGap as the Java wrapper for web applications. Currently Blackberry PhoneGap does work but the web control used to display web pages currently ignores all formatting so it makes it pretty much useless. When this is fixed (note this is a Blackberry issue) it will only be available to latest devices.

So how do you write the cross platform web applications. In general there is good consistency between the support for Javascript and CSS across iPhone, Android and S60. So you can write code once and run it everywhere. You need to be aware of screen size and there are two approaches to ensure good behaviour. Firstly you should try to use CSS styles like "width: 100%" where possible. This is needed both within the application as well as support between devices - within the application support for portrait and landscape modes helps if you use these styles. However there are times when you need to know the screen dimensions so the following 2 variables are very useful:

var screenWidth = window.innerWidth;
var screenHeight = window.innerHeight;

These variables need to be set on a timer to cope with switching between portrait and landscape modes - there is no consistent javascript event to detect this scenario currently. Once you know the screen size then the font size can be set using Javascript to change the CSS style sheet. This is need for the S60 Ed5 phones with 360x640 pixels - in this case we would have a command "font-size: 170%" just get the font readable on these devices.

Meanwhile some of the PhoneGap developers are creating a common layer of Javascript code to deal with the native APIs for accessing GPS information, the address book and saving data locally. They do not include S60 but the translation between the two approaches is not too difficult. In fact saving data locally can be achieved purely in Javascript for iPhone, Android and S60 WRT apps and does not need the native wrapper involvement.

Conclusion:

Think twice about porting.  If you can write your code just once then this is a major advantage.  You just need to ensure that you screen does not need to update too quickly.

 

 

 

RSSComments

Apple has major problems with PhoneGap

JOM | 13/05/2009, 00:28

JOM

To summarize: you recommend using PhoneGap? Well, Apple doesn't like that at all, in fact several sites go to great lenghts to explain how to HIDE PhoneGap! One example:

http://phonegap.pbworks.com/Remove-PhoneGap-References

That can't be too portable or future-proof coding :) What's more worrying is that Apple "seems" to consider PhoneGap and similar app frameworks as potential security risks:

http://britg.com/tags/phonegap/

"As has been pointed out, this is rejected because it allows an external application to access information about the iPhone."

While app frameworks are great, the situation doesn't seem to be very clear. Fortunately this doesn't seem to be a problem for Nokia, considering how Platform Services API has been made available just about for everyone using any development language/framework.

Cheers,

--jouni

Apple and PhoneGap

robin.jewsbury | 14/05/2009, 01:21

robin.jewsbury

Apple actually like to fully pre-define/control the content in applications. The issue they have with some PhoneGap applications is that if Internet content is shown they cannot predict what that content is. Its nothing to do with security its more to do with the potential for offensive content and not specifically PhoneGap or frameworks either. There are 100s of phone gap applications on the iPhone Appstore and there are also quite a few cases of rejected ones and quite a lot of cases of Apple rejecting other applications too. One of the issues around rejections is Apple never give much information on the rejection reason so its results in all sorts of stories and assumptions building up.

You must login to post comments. Login
 

Rate This

 
 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fblogsE2eforumE2enokiaE2ecomE2fblogE2fforumE2dnokiaE2dwebE2ddeveloperE2dalertE2f2009E2f11E2f02E2fnokiaE2dmobileE2dwebE2dtemplatesX qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZBlogContentQ qdcZtypeQUqfntypeZBlogE45ntryQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtopicQUxhttpE3aE2fE2fswE2enokiaE2ecomE2fFNE2d1E2fBlogTopicE2fgeneralX qfnZtopicQUqfnTopicZbrowsingQ qfnZtopicQUqfnTopicZwebE5ftechnologyQ qfnZtypeQUqfntypeZBlogContentQ qfnZtypeQUqfntypeZBlogE45ntryQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZBlogContentQ qrdfZtypeQUqfntypeZBlogE45ntryQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ
User Rating: qfnZuserE5FratingQNx5E2E0000X