Feb 13, 2009

Touch enabling Java ME applications

I was reading a mini review of the Nokia 5800 xpressmusic phone. Blog entry complains some that even though the phone has a big screen, the virtual keypad takes a lot of space and the Java applications can not really take advantage of the screen estate. I think the below screenshots of the same MIDlet with and without the virtual keypad illustrates the problem. Actually, this problem is not entirely phones fault.
LCDUI application without virtual keypadLCDUI application with keypad
One interesting fact about the Nokia 5800 is it is the first touch phone that carries eSWT on the device. If you are a developer who is using eSWT to develop Java ME applications, (or  a user using only eSWT applications),  you can stop reading here and enjoy your favorite beverage. eSWT does not have a virtual keypad that takes screen estate so the below explanation does NOT apply to eSWT applications.
I should first start by explaining why do we have the virtual keypad anyway. The main reason for Nokia to carry eSWT as an alternate UI toolkit on devices is MIDP’s UI toolkit (LCDUI) lacks the flexibility and the features that are available on modern smartphone platforms. In order to overcome the lack of features, MIDP developers create their own UI components using the basic graphics drawing capabilities of LCDUI on a full screen Canvas. Many of the applications (GMail mobile client, Opera mini etc. ) today draw their widgets. There are even UI toolkits that are build on the same design. These applications and frameworks are not based on the components of the platform, as a result they need to handle the touch interaction themselves. Since the size of the touch enabled Java ME device market was small, most applications ignored touch and did not have this support . Hence, the virtual keypad was introduced to touch devices so that the applications would still work even if they were not adjusted to touch use by its developers.
Now the instructions on how to get rid of the virtual keypad on a Nokia S60 device?"
As a user, there is a well hidden preference that you can use to disable to keypad. It can be reached from Settings –> Application Mgr. –>Installed Apps. then select your MIDlet from the list and goto Suite Settings, On Screen Keyboard is the first option.
As a developer,  If you have enabled touch for your application then you can use the Nokia-MIDlet-On-Screen-Keypad attribute to configure the virtual keypad feature. More information on the attribute is available in this wiki article. Another good resource for touch enabling Java ME applications is this JavaOne presentation that I and Aleksi Uotila presented last year.