views:

336

answers:

1

Hello,

I'm writing a MIDlet using the Kuix UI toolkit, and I want to make changes to the toolkit depending on whether the current device is a touch screen device. (These changes include making buttons bigger, for easier tapping.)

Is there a way to detect whether the device has a touch screen using J2ME (MIDP 2)?

[edit] as a (crappy) workaround I check for the screen height instead. A screen width a height of higher than 240 is likely a touch screen... Please let me know if there are any more effective ways.

+2  A: 

Hi, try Canvas.hasPointerEvents() -- it seems to be an instance method. No idea why this isn't static.

http://java.sun.com/javame/reference/apis/jsr118/javax/microedition/lcdui/Canvas.html

Checks if the platform supports pointer press and release events.

Chris Dennett
That method returns true on my non-touch emulators. I don't have access to a physical j2me device right now, but I'll try it out when I can. Thanks.
benvd
Alright, it does work on actual j2me devices. Apparently some emulators report themselves as touch devices, while they in fact aren't. Thanks!
benvd