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.
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.
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
精彩评论