0

我在“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;
            }

       }
4

2 回答 2

0

不要将用户传递给 Maps 应用程序,它位于您的应用程序之外并且您无法控制它,而是创建您自己的屏幕,其中包含一个MapField。如果需要,使用您自己的屏幕并可能扩展 MapField 类以覆盖函数,一旦用户选择一个位置,您就可以返回到前一个屏幕。

于 2011-12-23T15:15:40.820 回答
0

不幸的是,您不能以编程方式关闭另一个应用程序(实际上,如果您知道要关闭的菜单项在哪里,则可以),但您可以将您的应用程序置于前台UiApplication.getApplication().requestForeground()。什么可能是适合您的解决方案。

于 2011-12-23T00:11:04.747 回答