×
Namespaces

Variants
Actions
(Difference between revisions)

How to get device Java ME configuration information

From Nokia Developer Wiki
Jump to: navigation, search
Mayurvihaar (Talk | contribs)
(This article Shows basic Configuration of Your Mobile phone)
 
jappit (Talk | contribs)
(Code indented and enclosed in code tags)
Line 1: Line 1:
 
This is a very simple code of j2me. By implementing it, and running it by your mobile device, you could learn some attributes of Java configuration of your mobile device.
 
This is a very simple code of j2me. By implementing it, and running it by your mobile device, you could learn some attributes of Java configuration of your mobile device.
 
+
<code java>
 
import javax.microedition.midlet.*;
 
import javax.microedition.midlet.*;
 
import javax.microedition.lcdui.*;
 
import javax.microedition.lcdui.*;
 
public class AttributesMIDlet extends MIDlet{
 
public class AttributesMIDlet extends MIDlet{
private Display display;
+
private Display display;
private Command cExit;
+
private Command cExit;
public void startApp(){
+
public void startApp(){
display = Display.getDisplay(this);
+
display = Display.getDisplay(this);
cExit = new Command(”Quit”, Command.EXIT, 0);
+
cExit = new Command(”Quit”, Command.EXIT, 0);
Canvas canvas = new DummyCanvas();
+
Canvas canvas = new DummyCanvas();
Runtime runtime = Runtime.getRuntime();
+
Runtime runtime = Runtime.getRuntime();
Form form = new Form(”Attributes”);
+
Form form = new Form(”Attributes”);
form.append(new StringItem(”Know Your Mobile”, “”));
+
form.append(new StringItem(”Know Your Mobile”, “”));
form.append(new StringItem(”Total Memory:”, String.valueOf(runtime.totalMemory()/1024)+”Kb”));
+
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(”Free Memory:”, String.valueOf(runtime.freeMemory()/1024)+”Kb”));
form.append(new StringItem(”n”, null));
+
form.append(new StringItem(”n”, null));
form.append(System.getProperty(”microedition.configuration”));
+
form.append(System.getProperty(”microedition.configuration”));
form.append(System.getProperty(”microedition.profiles”));
+
form.append(System.getProperty(”microedition.profiles”));
boolean isColor = display.isColor();
+
boolean isColor = display.isColor();
form.append(new StringItem(isColor ? “Colors:”: “Grays:”, String.valueOf(display.numColors())));
+
form.append(new StringItem(isColor ? “Colors:”: “Grays:”, String.valueOf(display.numColors())));
form.append(new StringItem(”Width: “, String.valueOf(canvas.getWidth())));
+
form.append(new StringItem(”Width: “, String.valueOf(canvas.getWidth())));
form.append(new StringItem(”Height:”, String.valueOf(canvas.getHeight())));
+
form.append(new StringItem(”Height:”, String.valueOf(canvas.getHeight())));
form.append(new StringItem(”Repeat:”, String.valueOf(canvas.hasRepeatEvents())));
+
form.append(new StringItem(”Repeat:”, String.valueOf(canvas.hasRepeatEvents())));
form.append(new StringItem(”Double Buff:”, String.valueOf(canvas.isDoubleBuffered())));
+
form.append(new StringItem(”Double Buff:”, String.valueOf(canvas.isDoubleBuffered())));
form.addCommand(cExit);
+
form.addCommand(cExit);
form.setCommandListener(
+
form.setCommandListener(
new CommandListener(){
+
new CommandListener(){
public void commandAction(Command c, Displayable d){
+
public void commandAction(Command c, Displayable d){
if (c == cExit){
+
if (c == cExit){
destroyApp(false);
+
destroyApp(false);
notifyDestroyed();
+
notifyDestroyed();
}
+
}
}
+
}
}
+
}
);
+
);
display.setCurrent(form);[[Category:[[Category:Java ME]]]]
+
display.setCurrent(form);[[Category:[[Category:Java ME]]]]
}
+
}
public void pauseApp(){
+
public void pauseApp(){
}
+
}
public void destroyApp(boolean unconditional){
+
public void destroyApp(boolean unconditional){
}
+
}
 
}
 
}
 
class DummyCanvas extends Canvas{
 
class DummyCanvas extends Canvas{
public void paint(Graphics g){
+
public void paint(Graphics g){
;
+
;
}
+
}
 
}
 
}
 +
</code>

Revision as of 22:47, 23 January 2009

This is a very simple code of j2me. By implementing it, and running it by your mobile device, you could learn some attributes of Java configuration of your mobile device.

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){
;
}
}
81 page views in the last 30 days.
×