So I used the pure j2me approach:
Using javax.microedition.lcdui.Canvas you can determine whether a device has touch screen support by calling the hasPointerEvents() method. Because Canvas is abstract class you should provide a dummy implementation similar to the one I offer. The following code is tested and works on actual Blackberry devices and it should also work on other devices but I haven't tested it.
import javax.microedition.lcdui.Canvas; import javax.microedition.lcdui.Graphics; public class TouchSupportInfo extends Canvas { private static TouchSupportInfo instance; private TouchSupportInfo(){ } public static TouchSupportInfo getInstance(){ if( instance == null ){ instance = new TouchSupportInfo(); } return instance; } protected void paint(Graphics g) { //leave empty } public boolean isTouchScreenDevice(){ return hasPointerEvents(); } }
Няма коментари:
Публикуване на коментар