我为Blackberry创建了一个自己的菜单项,借助“MenuItem”并调用黑莓地图。在使用这个Item之后,当前位置(MapView)应该被发送回我的应用程序。这工作正常。关闭使用自定义菜单项后的黑莓地图
问题是我发现使用菜单项后关闭应用程序没有解决方案。是否有可能关闭黑莓地图?或将我自己的应用程序设置为前景?
private static class MapMenuItem extends ApplicationMenuItem {
//creates a new MenuItem for Blackberry Maps and defines the action which should //happen after a click on the MenuItem
CustomDialog_GPS customDialogGps;
StartScreen startScreen;
MapMenuItem(StartScreen startScreen, CustomDialog_GPS customDialogGps) {
super(20);
this.startScreen = startScreen;
this.customDialogGps = customDialogGps;
}
public String toString() {
//creates the name for the navigation Menu
String itemName = ""+_res.getString(CUSTOMDIALOG_GPS_USE_AS_NEW_LOCATION);
return itemName;
}
public Object run(Object context) {
//defines what should happen after a click on the menu
//get the location at which the cursor is pointing at.
MapView mv = (MapView)context;
if (mv != null) {
//opens a method inside of CustomDialogGPS which handles the latitude and longitude
customDialogGps.saveAdjustedPosition(mv);
//TODO pop Screen
//Screen screen = (Screen)UiApplication.getUiApplication().getActiveScreen();
}
else {
throw new IllegalStateException("Context is null, expected a MapView instance");
}
return null;
}
}
我不确定我明白...用户不应该关闭地图以返回到您的应用程序吗?为什么你的应用程序要关闭地图? – Tamar 2011-12-22 16:25:57
我打开黑莓地图来定义一个位置并获取GPS坐标。如果用户选择了黑莓地图中的位置,他应该使用menue项,其中指出“使用这个位置”。当前的地图视图发送到应用程序,应用程序处理地图视图的坐标。但问题是黑莓地图仍然是开放的:/和用户必须关闭黑莓地图才能返回到应用程序... – Martin 2011-12-22 16:42:17
为什么你需要从地图中获取位置?为什么不使用LocationProvider获取当前位置? – Tamar 2011-12-22 19:14:11