Category Archives: Mobile Devices

J2ME Recipe Viewer update & code samples

Hey, it’s working! 🙂 I ironed out the problems I was having with my J2ME Recipe Viewer application. Couple things I did to make it purr:

First, I mentioned that I was getting an IO error when trying to make a wireless connection using the phone, it became apparent that I needed way better error handling in the application once it moved from the WTK emulator phase (where I could System.out.println) to the actual phone. So I created a Form that took a String message as an argument to the constructor and then appended the String to the Form. Then in the two Thread classes that I used, if I got an error, I’d simply add the error message to the Form and use the DisplayManager (from the Core J2ME book, you can download the code) to pop that form to displayable:

midlet.displayManager.pushDisplayable(new FormError(midlet, error.toString()));

Second, I noticed that the getType() method of the HttpConnection object wasn’t returning “text/xml” like it was on the emulator, instead it was returning


which means that the AT&T proxy is messing with the response header that I’m sending from my webserver. Because my logic looked like this:

if (code == HttpConnection.HTTP_OK && type.equals(“text/xml”)) {

after attempting to connect to my web server, I was never able to get to the XML parsing and subsequent handoff to the next screen. Anyway, I removed the check on the type (why did I have it in the first place? I don’t know…) and then everything worked!

After I got it working on the phone, I wanted to fine tune some of the other things I thought were kludgy about the app. Both the ListRecipes and ListCategory classes (which both extend the MIDP List class) presented a list of choices to the user and then on select would do two things: a) they would present an Alert to the user and then b) would start a Thread responsible for making a wireless HTTP connection, which itself would then redraw the screen with the result of the HTTP connection. The thinking behind this is probably common sense to someone who’s been developing non web-apps for some time, but it was something that I learned about while sitting in the back row of TS-2037: “Advanced MIDP Programming: Developing High Performance, Highly Responsive Wireless Applications” [download the pdf, it’s got 91 very useful slides on MIDP UI]. The problem with this approach is that the Alert dismisses itself after a set period of time (in this case 3 seconds) which resulted in a weird user interface. You’d select “Breakfast”, see an alert for 3 seconds, see the recipe categories again, and then a couple seconds later would see the breakfast recipes. So instead of an Alert, I created another Form that took a String as an argument to its constructor and then displayed that Form… which would not dismiss itself and then let the Thread take care of redrawing the screen.

Finally, I updated the search form that it too starts up a Thread, which connects to the webserver, which returns XML and then displays a list of matching recipes.

You can download the updated J2ME app and source:

RecipeViewer source

J2ME Recipe Browser

As an exercise, I wrote up a J2ME client for As I mentioned a couple days ago, it sends HTTP requests to a servlet to receive a list of recipes as XML, and then (given a specific recipe), sends another HTTP request for the recipe details (again returned as XML). It works great on the emulator, not so good on the 3650. It looks like the phone can’t establish a connection to my server, because as I tail the Apache logs, I don’t see the request come through (I do see the request when using the emulator). I’m guessing it has something to do with the default connection for Java apps on the phone. Anyone have any experience with making wireless connections on the 3650 through J2ME?

If you’re interested, you can download the application and the source:

RecipeViewer source

VS Httpd

VS Httpd is a small HTTP server for the Symbian Series 60 phones whose main purpose is to provide web access to images stored on the phone. You can download it here.

I installed with no problems but couldn’t view any documents on the phone, the phone was picking up a 10.x.x.x ip address, which I believe is a private IP behind the AT&T wireless proxy. Not sure if I’ll be able to make any use of this. Anyone else able to get it working?

[update: I found the readme.txt file on the system using fexplorer, according to it neither T-Mobile or AT&T give you publicly addressable ip addresses. Bummer.]


I downloaded and installed ScreenTaker by SymbianWare, a nifty little piece of software that gives you the ability to take screen shots of the applications on your Symbian based phone. If you’re using it on the 3650, you should read the instructions on the website, don’t pay attention to the instructions that come with the application. You should press ‘Pencil key + Menu key’ or ‘Pencil key + *’ to take a screen shot.

The picture above is a screen shot taken of my J2ME stopwatch application. I updated the jar & jad files tonight.. download’em again if it didn’t work for you the first time.

Built-in simple task manager

From the Handango newsletter in my inbox today:

Built-in simple task manager for Series 60 devices
Press and hold the Menu button located on the left side of the display. You will be presented with a list of all applications currently running in your system. You can quickly switch to any of the running tasks by selecting it and pressing the joystick. You can also close a task by selecting it and pressing “C”.

More Series 60 tips