24SevenOffice

Ajax-based ERP/CRM with accounting, invoicing, crm, calendar, e-mail and more.

Writing applications for mobile phones

Your typical mobile phone is packed with potential. Come think about it, my old 120 mHz pentium had issues playing .mp3 files, let alone combining .mp3 playback with say opening an MsPaint picture. Your mobile probably does this skip-free.

Covering most of the alphabet, keywords like J2ME, CLDC, MIDP, WTK and so on make up the mobile Sun Java platform and is supported by most mobile phones. Write once, play anywhere, it’s all free and it’s easy getting started. So they claim.

John Carmack, founder of id software and the 3D guru behind titles like Doom, Quake and eh.. Commander Keen puts things in perspective in his blog. id’s game Doom II has been opened source-wise, copied, cloned, improved and put into every thinkable device that has a screen, like the iPod or the Game Boy platform. But even though the game is said to have run smoothly on the electrical wirings on a Kawasaki motorcycle, John Carmack apparently is not that optimistic when it comes to porting the game to mobile Java. “With Java, on most phones you are left with about the CPU power of an original 4.77 mhz IBM PC, and lousy control over everything”, Carmack says.

I’ve been working with mobile Java for some time now. Now first of all, it’s not that bad. But it’s not that good either. For example, here’s what the documentation says about screen refresh: “The change will typically not take effect immediately. It may be delayed so that it occurs between event delivery method calls, although it is not guaranteed to occur before the next event delivery method is called”. You’ll find yourself fighting these small issues all the time, and it will take some of the fun out of writing mobile games or applications.

Performance is really an issue. Especially when doing networking or database queries. Actually, you can’t do queries to the database at all as you have to write your own rowfilter class and go through the list of data enumeration from the database. Oh, and the database doesn’t really have tables. It’s more like a hashtable with an index and a value. Ask me, what really made the palm pilot world dominant years ago was a simple programming environment and good database support.

Another issue is that you get a compiler warning when doing network or database tasks in the main thread. Also, painting to the screen should be done in another thread. Therefore, you will have to leave your main thread, invoke a new thread that displays some status info or dialog to the screen and return to your main thread through a callback method. This also solves the issue of the indecisive timing when it comes to showing a dialog on the screen.

On the brighter side, the tools for developing mobile Java are free, runs ok and is quite easy to set up. I’ve been using Eclipse with a plug in called EclipseME and the official Java Wireless Toolkit (WTK) emulator from Sun. No hitches in installation or running Eclipse with the emulator. Last time I ran Eclipse, it would suddenly write backwards with inserts and other really annoying bugs happened all the time. So far, I’ve had absolutely no such problems with the IDE.

So if your goal is to make a simple game loop which writes some simple graphics onto the screen, getting started should be fun for the most part. If your goal is to make an application with several dialogs, screens, classes and plow a bit deeper into the platform, brace yourself for some work ahead. Be sure to catch a copy of the documentation and prepare to spend some time with it.

No Comments

No comments yet.

Comments RSS TrackBack Identifier URI

Leave a comment