2

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.

gnat
  • 6,213
  • 108
  • 53
  • 73
benvd
  • 5,776
  • 5
  • 39
  • 59
  • A lot of 240x320 (width x height) phones from Sony-Ericsson, Nokia and Samsung use keypads and don't have touch screens. – michael aubert Mar 19 '10 at 17:38
  • 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 Mar 22 '10 at 10:35
  • 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 Feb 11 '13 at 06:35

2 Answers2

3

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
  • 22,412
  • 8
  • 58
  • 84
  • 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 Mar 19 '10 at 16:52
  • Alright, it does work on actual j2me devices. Apparently some emulators report themselves as touch devices, while they in fact aren't. Thanks! – benvd Mar 22 '10 at 10:37
0

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

Atiq Rahman
  • 680
  • 6
  • 24