BlackberryMapsのために "MenuItem"を使用して独自のメニュー項目を作成し、Blackberry Mapsを呼び出しました。このアイテムを使用した後、現在の場所(MapView)を自分のアプリケーションに送り返す必要があります。これは正常に動作します。カスタムメニュー項目を使用した後のBlackberryマップを閉じる
問題は、メニュー項目を使用した後にアプリケーションを閉じるための解決策が見つかりませんでした。 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;
}
}
私は理解していません...あなたのアプリケーションに戻るためにマップを閉じるべきではありませんか?アプリケーションがマップを閉じるべき理由は何ですか? – Tamar
私はBlackberry Mapsを開いて場所を定義し、gps座標を取得します。ユーザーがブラックベリーマップの場所を選択した場合は、「これを場所として使用する」というmenue Itemを使用する必要があります。現在の地図ビューはアプリに送信され、アプリはマップビューの座標を処理します。しかし、問題はブラックベリーマップがまだ開いていることです:/そして、ユーザーはアプリケーションに戻るためにブラックベリーマップを閉じる必要があります... – Martin
なぜあなたは地図から場所を取得する必要がありますか? LocationProviderを使用して現在の場所を取得してみませんか? – Tamar