2
votes

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 lot of 240x320 (width x height) phones from Sony-Ericsson, Nokia and Samsung use keypads and don't have touch screens. - michael aubert
Thanks. The only changes I made, though, are UI-related (bigger buttons, bigger list items, bigger bottombar), so it's not that bad if they get applied to a non-touch device. I just want to avoid them being applied on devices that are already lacking in screen real estate. - benvd
hello ben, i have same problem with my project in kuix UI. I found your solution from kalmeo technical support. I want to improve it more have you any more suggestion for changing in kuix src framework. - Arpit Kulsreshtha

2 Answers

3
votes

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.

0
votes

in canvas this function will tell you whether you have touchDevice or not,

    public boolean isTouchDevice() {
            if (hasPointerEvents() && hasPointerMotionEvents())
                    return true;
            return false;
    }

For details, visit: http://library.developer.nokia.com/index.jsp?topic=/Java_Developers_Library/GUID-C7998A81-E7C0-4932-B7DE-3A0B166C077F.html