Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

Revision as of 07:39, 22 July 2013 by hamishwillee (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

How to get device Java ME configuration information

From Wiki
Jump to: navigation, search

This simple Java ME app gets information about the device Java configuration, including available memory, screen/canvas attributes, supported configurations and profiles.

Article Metadata
Article
Created: User:Mayurvihaar (23 Jan 2009)
Last edited: hamishwillee (22 Jul 2013)
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class AttributesMIDlet extends MIDlet{
private Display display;
private Command cExit;
public void startApp(){
display = Display.getDisplay(this);
cExit = new Command(”Quit”, Command.EXIT, 0);
Canvas canvas = new DummyCanvas();
Runtime runtime = Runtime.getRuntime();
Form form = new Form(Attributes);
form.append(new StringItem(”Know Your Mobile”, “”));
form.append(new StringItem(”Total Memory:”, String.valueOf(runtime.totalMemory()/1024)+”Kb”));
form.append(new StringItem(”Free Memory:”, String.valueOf(runtime.freeMemory()/1024)+”Kb”));
form.append(new StringItem(”n”, null));
form.append(System.getProperty(”microedition.configuration));
form.append(System.getProperty(”microedition.profiles));
boolean isColor = display.isColor();
form.append(new StringItem(isColor ? “Colors:: “Grays:”, String.valueOf(display.numColors())));
form.append(new StringItem(”Width: “, String.valueOf(canvas.getWidth())));
form.append(new StringItem(”Height:”, String.valueOf(canvas.getHeight())));
form.append(new StringItem(”Repeat:”, String.valueOf(canvas.hasRepeatEvents())));
form.append(new StringItem(Double Buff:”, String.valueOf(canvas.isDoubleBuffered())));
form.addCommand(cExit);
form.setCommandListener(
new CommandListener(){
public void commandAction(Command c, Displayable d){
if (c == cExit){
destroyApp(false);
notifyDestroyed();
}
}
}
);
display.setCurrent(form);[[Category:[[Category:Java ME]]]]
}
public void pauseApp(){
}
public void destroyApp(boolean unconditional){
}
}
class DummyCanvas extends Canvas{
public void paint(Graphics g){
;
}
}
This page was last modified on 22 July 2013, at 07:39.
46 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×