【发布时间】:2012-01-26 03:06:30
【问题描述】:
我在“MenuItem”的帮助下为 BlackberryMaps 创建了一个自己的菜单项并调用 Blackberry Maps。使用此项目后,当前位置(地图视图)应发送回我的应用程序。这很好用。
问题是我没有找到使用菜单项后关闭应用程序的解决方案。是否有可能关闭黑莓地图?或者将我自己的应用程序设置为前台?
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;
}
}
【问题讨论】:
-
我不确定我是否理解...用户不应该关闭地图以返回您的应用程序吗?为什么您的应用程序要关闭地图?
-
我打开 Blackberry Maps 以定义位置并获取 gps 坐标。如果用户在黑莓地图中选择了位置,他应该使用显示“将其用作位置”的菜单项。当前的地图视图被发送到应用程序,应用程序处理地图视图的坐标。但问题是黑莓地图仍然打开:/ 用户必须关闭黑莓地图才能返回应用程序...
-
为什么需要从地图中获取位置?为什么不使用 LocationProvider 获取当前位置?
-
在这个应用程序中,我需要一个用户定义的位置,该位置应该可以在黑莓地图上选择。
-
我明白了,我在下面添加了一个关于如何实现此效果的答案。希望这会有所帮助!
标签: blackberry blackberry-maps