Tuesday, 10 September 2013

unable to display sensor info on j2me

unable to display sensor info on j2me

I've have written the following code to display the sensors available on
the Nokia Asha phones.
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.List;
import javax.microedition.sensor.*;
public class Sensor extends Midlet {
private Display display;
private List sensorList;
private SensorInfo[] sensorinfo;
private Command exit, list;
public void SensorBrowser(){
display = Display.getDisplay(this);
sensorList = new List("Available Sensors", List.EXCLUSIVE);
sensorinfo = SensorManager.findSensors(null, null);
for(int i = 0; i<sensorinfo.length; i++){
System.out.println("Sensor #" + (i+1) + ": Description: "
+ sensorinfo[i].getDescription());
}
exit = new Command("Exit", Command.EXIT, 1);
list = new Command("Description", Command.ITEM, 1);
sensorList.addCommand(list);
sensorList.addCommand(exit);
sensorList.setCommandListener((CommandListener) this);
}
}
When I try to run it on Asha Emulator, all I get is a blank screen.
This may seem like a basic question to many, but I'm new to j2me platform
and I could not find any help in this matter.
Thank you.

No comments:

Post a Comment