0

「MenuItem」を使用して BlackberryMaps 用に独自のメニュー項目を作成し、Blackberry Maps を呼び出しました。このアイテムを使用した後、現在の場所 (MapView) をアプリケーションに送り返す必要があります。これはうまくいきます。

問題は、メニュー項目を使用した後にアプリを閉じるための解決策が見つからなかったことです。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

残念ながら、プログラムで別のアプリを閉じることはできません (たとえば、閉じるメニュー項目がどこにあるかがわかっている場合は実際にできます) が、 app をフォアグラウンドにすることはできますUiApplication.getApplication().requestForeground()。おそらくあなたにとって適切な解決策は何ですか。

于 2011-12-23T00:11:04.747 に答える