package test; import javax.microedition.lcdui.Command; import javax.microedition.lcdui.CommandListener; import javax.microedition.lcdui.Display; import javax.microedition.lcdui.Displayable; import javax.microedition.lcdui.Form; import javax.microedition.midlet.MIDlet; public class Main extends MIDlet { private static Main instance = null; private Display display = null; private Displayable form = null; public Main() { instance = this; } protected void startApp() { if (display == null) { // 首次启动应用程序 display = Display.getDisplay(this); form = new TestForm(); display.setCurrent(form); } else { display.setCurrent(form); } } protected void pauseApp() { } protected void destroyApp(boolean unconditional) { } public static void quitApp() { instance.destroyApp(true); instance.notifyDestroyed(); instance = null; } } class TestForm extends Form implements CommandListener { private Command exit = new Command("退出", Command.EXIT, 0); public TestForm() { super("J2ME平台测试"); String s; // CLDC版本属性 s = System.getProperty("microedition.configuration"); append(getValue("CLDC版本", s)); // MIPD版本属性 s = System.getProperty("microedition.profiles"); append(getValue("MIDP版本", s)); s = System.getProperty("microedition.platform"); append(getValue("软件平台", s)); s = System.getProperty("microedition.encoding"); append(getValue("系统编码", s)); s = System.getProperty("microedition.locale"); append(getValue("区域设置", s)); s = System.getProperty("microedition.jtwi.version"); append(getValue("JTWI", s)); // 判断是否支持MMAPI s = System.getProperty("microedition.media.version"); append(getValue("MMAPI", s)); // 判断是否支持WMA s = System.getProperty("wireless.messaging.sms.smsc"); if (s != null) { append(getValue("WMA", "支持")); append(getValue("SMS", s)); s = System.getProperty("wireless.messaging.mms.mmsc"); append(getValue("MMS", s)); } else append(getValue("WMA", null)); // 判断是否支持蓝牙 s = System.getProperty("bluetooth.api.version"); append(getValue("蓝牙", s)); // 判断是否支持个人信息管理 s = System.getProperty("microedition.pim.version"); append(getValue("PIM", s)); // 判断是否支持文件系统 s = System.getProperty("microedition.io.file.FileConnection. version"); append(getValue("FileConnection", s)); // 判断是否支持SIP s = System.getProperty("microedition.sip.version"); append(getValue("SIP", s)); // 判断是否支持M3G JSR 184 s = System.getProperty("microedition.m3g.version"); append(getValue("M3G", s)); addCommand(exit); setCommandListener(this); } private String getValue(String prompt, String s) { return prompt + ":" + (s == null ? "不支持" : s) + "/n"; } public void commandAction(Command c, Displayable d) { if (c == exit) { // System.exit(0); Main.quitApp(); } } }