Revision: 1771
Updated Code
at November 10, 2006 00:05 by whitetiger
Updated Code
package System; import javax.microedition.lcdui.Alert; import javax.microedition.lcdui.AlertType; 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; import javax.microedition.midlet.MIDletStateChangeException; public class SystemProperties extends MIDlet implements CommandListener { private Command esci; private Display display; private Form form; protected void startApp() throws MIDletStateChangeException { display = Display.getDisplay(this); form = new Form("System Propiertis"); form.setCommandListener(this); esci = new Command("Esci", Command.EXIT, 0); form.addCommand(esci); Runtime rt = Runtime.getRuntime(); rt.gc(); // Garbage Collection form.append("Free Memory: " + rt.freeMemory() + "\n"); form.append("Total Memory: " + rt.totalMemory() + "\n"); form.append(showProp("microedition.configuration")); form.append(showProp("microedition.platform")); form.append(showProp("microedition.locale")); form.append(showProp("microedition.encoding")); form.append(showProp("microedition.encodingClass")); form.append(showProp("microedition.http_proxy")); display.setCurrent(form); } protected void pauseApp() { } protected void destroyApp(boolean unconditional) throws MIDletStateChangeException { notifyDestroyed(); } public String showProp(String str) { String value = System.getProperty(str); StringBuffer stringbuffer = new StringBuffer(50); stringbuffer.setLength(0); stringbuffer.append(str); stringbuffer.append(" = "); if(value == null) stringbuffer.append("<undefined>"); else { stringbuffer.append("\""); stringbuffer.append(value); stringbuffer.append("\""); } stringbuffer.append("\n"); return stringbuffer.toString(); } public void commandAction(Command c, Displayable d) { if(c == esci) { try { destroyApp(true); } catch(MIDletStateChangeException e) { showException(e); } } } public void showException(Exception e) { Alert alert = new Alert("Errore !!!"); alert.setString(e.getMessage()); alert.setType(AlertType.ERROR); alert.setTimeout(Alert.FOREVER); display.setCurrent(alert); } }
Revision: 1770
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at November 9, 2006 23:55 by whitetiger
Initial Code
package System; import javax.microedition.lcdui.Alert; import javax.microedition.lcdui.AlertType; 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; import javax.microedition.midlet.MIDletStateChangeException; public class SystemProperties extends MIDlet implements CommandListener { private Command esci; private Display display; private Form form; protected void startApp() throws MIDletStateChangeException { display = Display.getDisplay(this); form = new Form("System Propiertis"); form.setCommandListener(this); esci = new Command("Esci", Command.EXIT, 0); form.addCommand(esci); Runtime rt = Runtime.getRuntime(); rt.gc(); // Garbage Collection form.append("Free Memory: " + rt.freeMemory() + "\n"); form.append("Total Memory: " + rt.totalMemory() + "\n"); form.append(showProp("microedition.configuration")); form.append(showProp("microedition.platform")); form.append(showProp("microedition.locale")); form.append(showProp("microedition.encoding")); form.append(showProp("microedition.encodingClass")); form.append(showProp("microedition.http_proxy")); display.setCurrent(form); } protected void pauseApp() { } protected void destroyApp(boolean unconditional) throws MIDletStateChangeException { notifyDestroyed(); } public String showProp(String str) { String value = System.getProperty(str); StringBuffer stringbuffer = new StringBuffer(50); stringbuffer.setLength(0); stringbuffer.append(str); stringbuffer.append(" = "); if(value == null) stringbuffer.append("<undefined>"); else { stringbuffer.append("\""); stringbuffer.append(value); stringbuffer.append("\""); } stringbuffer.append("\n"); return stringbuffer.toString(); } public void commandAction(Command c, Displayable d) { if(c == esci) { try { destroyApp(true); } catch(MIDletStateChangeException e) { showException(e); } } } public void showException(Exception e) { Alert alert = new Alert("Errore !!!"); alert.setString(e.getMessage()); alert.setType(AlertType.ERROR); alert.setTimeout(Alert.FOREVER); display.setCurrent(alert); } }
Initial URL
Initial Description
Initial Title
J2ME - System Properties
Initial Tags
phone, image, java, text, images, mobile
Initial Language
Java