Parsing RSS feeds with J2ME and KXML

May 9th, 2008

Some days have passed since last J2ME tutorial, so here is a fresh new one!

Today we’ll see how parsing a RSS feed with J2me is easy using KXML library, a fast and small XML pull parser, expecially suited for constrained environments like mobile devices. A live sample, parsing the RSS feed of this blog, is available here.

J2ME Kxml rss parser screenshot

The detailed explanation of source code is available on my Forum Nokia Wiki article: J2ME RSS Parser with KXml. If you’re interested only in plain source code, you can pick it up here (it includes also the sample midlet you find on the emulator page). To use KXmlRssParser class, you must simply do:

KXmlRssParser parser = new KXmlRssParser();
 
Vector rssItems = parser.parse(yourFeedURL);

and the parse() method will return the complete list of parsed Items, as instances of RssItem class. Source code is of course simplified, for the purpose of this tutorial, as it only considers title, link and description tags of each <item>, but once you understand KXml logic you can extend it, without much effort, to include other infos from RSS feed.

Other resources you might find useful:

First iPhone game: AnimaLogic is back!

May 8th, 2008

Since iPhone’s arrive in Italy seems to be near, here’s a first port of AnimaLogic, one of the first web runtime games!

Iphone Animalogic puzzle game screenshot

You can try a first (very beta, as always :)) version here.

iPhone animalogic game qrcode

J2ME game code: let’s play Darts!

May 5th, 2008

Darts is an ideal game for mobile users, since it does only require few seconds for a match, and could be really helpful while waiting for a bus.. (If you must wait a bus in Rome, it’s easy you’ll become a Darts champion within a day :))

J2ME game darts screenshot

This simple game was originally included, as easter egg, in the midlet built for 2007 Edition of Rome JavaDay, to help folks being awake during long talks :) For a live test you can go directly to the emulator page.

2007 Rome JavaDay Midlet screenshot

Now, It’s source code is fully available to everyone to (ab)use, and please be kind with me for the total lack of comments…

Here is the source code, and the full sample midlet if you want to try it out on your phone.

How to implement a loading bar with J2me

April 30th, 2008

Do you need a simple, effective j2me loading bar for your long-running operations? And would you like to avoid using (horrible) forms and gauges? Here’s a simple component you can freely use, modify or even ignore :)

j2me canvas loading bar

You can see a live preview on the emulator. To use it, you’ll simply instantiate and start it, like this:

LoadingBar bar = new LoadingBar(100, 40, 5, 10, 0xff0000);
bar.start();

For an explanation of source code you can go to my Forum Nokia Article: J2ME Canvas Loading Bar. If you simply want rude code, here it is: LoadingBar.java.

Mobile Web Server 1.3 released: ready to share!

April 30th, 2008

Mobile Web Server has reached 1.3 version, and It’s time to give it a try!

Mobile Web Server

The setup process is really simple: you must register, and then download the software (a single SIS installer). Done that, you’re ready to share all your phone content! More in details, here are the features of the last release:

  • Guest and friend user accounts
  • Calendar - manage your calendar, and share your availability for others too
  • Messaging - SMS inbox/outbox and SMS sending
  • Phone log - view missed calls
  • Contacts - manage your contacts easily
  • Blog - tell stories on your journeys
  • Camera - share instant pictures
  • Gallery - browse pictures taken with camera phone, and share them to others
  • Guestbook - visitors can leave their comments
  • Contact me - visitors can send instant messages to you
  • Presence - share your status and device state
  • Web chat - communicate with friends

The concept behind it is really attractive: have your web server always with you, and share things without the need to upload anything anywhere. Even letting users use your phone features, like taking instant picture with the phone camera!

Mobile Web Service using phone Camera

For sure, at least here in Italy, network speed and operator plans should evolve a bit to fully allow this technology to be really used. Also, with a lot of tools to upload you content on your favorite sites, I’m a bit unsure about the real target, in terms of users and possible usages, of this product.

Said that, I definitely think It’s cool, at least for real geeks!

And, for the curious out there, if you want to browse my phone content, you can simply go to: http://jappit.mymobilesite.net.

TvProgrammi.com goes mobile!

April 29th, 2008

TvProgrammi.com, the Italian TV guide, finally has its mobile version!

TvProgrammi mobile

If you have a phone supporting J2me (MIDP 2.0), you can download its first version directly from www.tvprogrammi.com.

Navigation is really straightfoward:

  • 1 .. 9 keys allow channel switching
  • left/right keys change the selected date
  • up/down keys scroll the program text
  • left soft key updates programs informations
  • right soft key closes the application

This version is not suitable for devices with small displays (let’s say, with a width of less than 128px), but for those a new version will be released soon.

New KuneriLite version with cool improvements

April 28th, 2008

KuneriLite is a great tool to extend FlashLite functionalities adding support for native features like local filesystem read/write, camera recording, accelerometer capabilities and much more. All these without the need to have any Symbian knowledge.

Practically, you interact with KuneriLite engine via localhost calls. For example, if you want to get recursive folder listing starting from current application base path, you can simply do:

loadVariables("http://127.0.0.1:1001/Basic/file?
klCommand=dir&klPath=\\&klArgs=/s", targetMc);

Their tool comes with an integrated wizard and an emulator, to be used with Symbian S60 3rd edition SDK Maintenance Release, to allow full development without the need of a real device.

KuneriLite logo

Now they’ve just released 0.9.6.1 version, that fixes issues with Flash Lite 3 and add new cool features, as you can read on their blog, and it’s more than ever worth a try!

Google launches mobile image ads

April 24th, 2008

From Google Mobile Blog good news for mobile developers: Mobile Image Ads will allow us to integrate Google image ads within our mobile websites the same way, and with the same useful analysis and report tools, as their web counterpart.

Google Mobile Ads

At the moment is still unclear how, and if, these ads could be used within mobile applications, like with other mobile ads services (i.e. AdMob), but it’ll be worth investigating a bit :)

Web Compatibility Test for Mobile Browsers

April 24th, 2008

Mobile browsers are really grown up, and it’s a clear symptom of this the fact that W3C published a Compatibility Test for Mobile Browsers (found via Ajaxian). You can simply launch test page within your mobile browser and you’ll get visual feedbacks about supported features, including:

  • XMLHTTPRequest object support
  • <canvas> element with its Javascript API
  • contenteditable, to allow rich content editing
  • transparent PNG support
  • Dynamic SVG
  • CSS3 selectors

Test page will give you a visual feedback like this:

mobile acid test result

Where each green square means that a feature is supported on your phone, while it’s not with a red one.
If you want to give it a try just point your browser to this url: http://tinyurl.com/37e33p, or use this QR code:

Mobile acid test QR code

Building a fisheye menu in J2ME with JSR 226

April 24th, 2008

I’ve always loved fisheye menus but, while there are quite a lot of ready-to-use components for web applications, when it comes to mobile it’s hard to find something. What better reason to build one? :)

Since we’ll have dynamically resizable icons, a natural choice to build one with J2ME is JSR 226, that give us full support of SVG Tiny. This will limit portability of code, since this JSR is not supported on all J2me phones, but support is rapidly growing with latest generation phones.

As you’ll see, code is quite straightforward, and great part of it is dedicated to coordinates/size calculations, to create that “slide/resize” effect that is soooooo cool :)

J2ME fisheye menu

You can find menu source code on my Forum Nokia Wiki article: J2ME Fisheye Menu with JSR 226, or download sample midlet here (and source code here).