Hi, I am just learning J2ME. Can any one tell me why the code below fails to display a map but insteady displays a blank screen:
/* HelloMapMidlet */
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package simo.map;
import com.nokia.maps.common.ApplicationContext;
import javax.microedition.lcdui.Display;
import javax.microedition.midlet.MIDlet;
/**
* @author simon
*/
public class HelloMapMIDlet extends MIDlet{
public HelloMapMIDlet()
{
}
public void startApp() {
// Get your own app_id and token by registering at
// https://api.developer.nokia.com/ovi-api/ui/registration
ApplicationContext.getInstance().setAppID(" ");
ApplicationContext.getInstance().setToken(" ");
Display display = Display.getDisplay(this);
MyMapCanvas hellomap = new MyMapCanvas(display, this);
display.setCurrent(hellomap);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
}
/* MyMapCanvas*/
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author simon
*/
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package simo.map;
import com.nokia.maps.common.GeoCoordinate;
import com.nokia.maps.map.MapCanvas;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDlet;
/**
* @author simon
*/
public class MyMapCanvas extends MapCanvas implements CommandListener{
private final Command EXIT = new Command("Exit", Command.EXIT, 1);
protected MIDlet midlet; // for notifyDestroyed
public MyMapCanvas(Display display, MIDlet midlet) {
super(display);
this.midlet = midlet;
addCommand(EXIT);
setCommandListener(this);
getMapDisplay().setZoomLevel(10, 0, 0);
getMapDisplay().setCenter(new GeoCoordinate(52.5, 13.4, 0));
}
/*
public void paint1(Graphics g){
paint(g);
}
*/
public void commandAction(final Command c, Displayable d) {
if (c == EXIT) {
midlet.notifyDestroyed();
} else {
commandRun(c);
}
}
protected void commandRun(Command c) {
// handle any other command
}
public void onMapUpdateError(String string, Throwable thrwbl, boolean bln) {
// add code for update error handling
}
public void onMapContentComplete() {
// add code for content updated handling
}
}

Reply With Quote


