2012-04-25 2 views
0

私は3つの主なアクティビティ(アクティビティ1、アクティビティ2、アクティビティ3)を持つプロジェクトを作成します。 アクティビティ1では、バンドルの番号を余分に渡します。余分なバンドルを使ってlng/latを渡すことはできません

newActivity.putExtra("LAT",Lata); 
newActivity.putExtra("LNG",Lnga); 

最後に、に:、イムこのように第三の活動に渡す、その後

 double Lata; 
    double Lnga; 

//in onCreate.. 
     Bundle extras = getIntent().getExtras(); 

     Lata = extras.getDouble("LAT"); 
     Lnga = extras.getDouble("LNG"); 

と:

newActivity.putExtra("LAT", getText(R.string.LAT1)); 
newActivity.putExtra("LNG", getText(R.string.LNG1)); 

、その後、第二いずれかで、私はこのような取得します3番目の活動:

public class mapview extends MapActivity 
{ 
@Override 
public void onCreate(Bundle savedInstanceState) 
{ 
super.onCreate(savedInstanceState); 
requestWindowFeature(Window.FEATURE_NO_TITLE); 

setContentView(R.layout.map); 

MapView mapView = (MapView) findViewById(R.id.mapview); 
mapView.setBuiltInZoomControls(true); 
//mapView.setSatellite(true); 
//mapView.setStreetView(true); 
List<Overlay> mapOverlays = mapView.getOverlays(); 
    Drawable drawable = this.getResources().getDrawable(R.drawable.pin); 
HelloItemizedOverlay itemizedoverlay = new HelloItemizedOverlay(drawable,this); 

Bundle extras = getIntent().getExtras(); 
final double Latc = extras.getDouble("LAT"); 
final double Lngc = extras.getDouble("LNG"); 
Integer txt_map = extras.getInt("MAP_NAME"); 





TextView mapname=(TextView)findViewById(R.id.museum_address_name); 
mapname.setText(getText(txt_map)); 

Double lat = Double.valueOf(Latc*1E6); 

    Double lng = Double.valueOf(Lngc*1E6); 

    //--------------------------------------------------- 
    GeoPoint center = new GeoPoint(Double.valueOf(Latc*1E6).intValue(), Double.valueOf(Lngc*1E6).intValue()); 
    MapController controller = mapView.getController(); 
     controller.setCenter(center); 
    controller.setZoom(15); 
    //--------------------------------------------------- 

    GeoPoint point = new GeoPoint(lat.intValue(), lng.intValue()); 
OverlayItem overlayitem = new OverlayItem(point, "", ""); 


itemizedoverlay.addOverlay(overlayitem); 

mapOverlays.add(itemizedoverlay); 
} 
@Override 
protected boolean isRouteDisplayed() 
{ 
return false; 
} 
} 

結果はどこかにあります南米では、しかし、私が間違って私の緯度と長いeurope..Whatにあるのでしょうか?イム2時間以上のためにそれを修正しようと... :(

EDIT

04-25 23:58:19.001: W/KeyCharacterMap(3746): No keyboard for id 0 
04-25 23:58:19.081: W/KeyCharacterMap(3746): Using default keymap: /system/usr/keychars/qwerty.kcm.bin 
04-25 23:58:22.461: W/Bundle(3746): Key LAT expected Double but value was a java.lang.Integer. The default value 0.0 was returned. 
04-25 23:58:22.481: W/Bundle(3746): Attempt to cast generated internal exception: 
04-25 23:58:22.481: W/Bundle(3746): java.lang.ClassCastException: java.lang.Integer 
04-25 23:58:22.481: W/Bundle(3746):  at android.os.Bundle.getDouble(Bundle.java:1017) 
04-25 23:58:22.481: W/Bundle(3746):  at android.os.Bundle.getDouble(Bundle.java:1000) 
04-25 23:58:22.481: W/Bundle(3746):  at kostas.menu.athensmuseums.museum_item.onCreate(museum_item.java:39) 
04-25 23:58:22.481: W/Bundle(3746):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 
04-25 23:58:22.481: W/Bundle(3746):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627) 
04-25 23:58:22.481: W/Bundle(3746):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679) 
04-25 23:58:22.481: W/Bundle(3746):  at android.app.ActivityThread.access$2300(ActivityThread.java:125) 
04-25 23:58:22.481: W/Bundle(3746):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033) 
04-25 23:58:22.481: W/Bundle(3746):  at android.os.Handler.dispatchMessage(Handler.java:99) 
04-25 23:58:22.481: W/Bundle(3746):  at android.os.Looper.loop(Looper.java:123) 
04-25 23:58:22.481: W/Bundle(3746):  at android.app.ActivityThread.main(ActivityThread.java:4627) 
04-25 23:58:22.481: W/Bundle(3746):  at java.lang.reflect.Method.invokeNative(Native Method) 
04-25 23:58:22.481: W/Bundle(3746):  at java.lang.reflect.Method.invoke(Method.java:521) 
04-25 23:58:22.481: W/Bundle(3746):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) 
04-25 23:58:22.481: W/Bundle(3746):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 
04-25 23:58:22.481: W/Bundle(3746):  at dalvik.system.NativeStart.main(Native Method) 
04-25 23:58:22.481: W/Bundle(3746): Key LNG expected Double but value was a java.lang.Integer. The default value 0.0 was returned. 
04-25 23:58:22.491: W/Bundle(3746): Attempt to cast generated internal exception: 
04-25 23:58:22.491: W/Bundle(3746): java.lang.ClassCastException: java.lang.Integer 
04-25 23:58:22.491: W/Bundle(3746):  at android.os.Bundle.getDouble(Bundle.java:1017) 
04-25 23:58:22.491: W/Bundle(3746):  at android.os.Bundle.getDouble(Bundle.java:1000) 
04-25 23:58:22.491: W/Bundle(3746):  at kostas.menu.athensmuseums.museum_item.onCreate(museum_item.java:40) 
04-25 23:58:22.491: W/Bundle(3746):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 
04-25 23:58:22.491: W/Bundle(3746):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627) 
04-25 23:58:22.491: W/Bundle(3746):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679) 
04-25 23:58:22.491: W/Bundle(3746):  at android.app.ActivityThread.access$2300(ActivityThread.java:125) 
04-25 23:58:22.491: W/Bundle(3746):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033) 
04-25 23:58:22.491: W/Bundle(3746):  at android.os.Handler.dispatchMessage(Handler.java:99) 
04-25 23:58:22.491: W/Bundle(3746):  at android.os.Looper.loop(Looper.java:123) 
04-25 23:58:22.491: W/Bundle(3746):  at android.app.ActivityThread.main(ActivityThread.java:4627) 
04-25 23:58:22.491: W/Bundle(3746):  at java.lang.reflect.Method.invokeNative(Native Method) 
04-25 23:58:22.491: W/Bundle(3746):  at java.lang.reflect.Method.invoke(Method.java:521) 
04-25 23:58:22.491: W/Bundle(3746):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) 
04-25 23:58:22.491: W/Bundle(3746):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 
04-25 23:58:22.491: W/Bundle(3746):  at dalvik.system.NativeStart.main(Native Method) 
04-25 23:58:24.251: W/MapActivity(3746): Recycling dispatcher [email protected] 
+0

実際に新しいアクティビティを開始するときにバンドルを添付していますか? – Tony

+0

getText(R.string.LAT1)、この行は何をしますか? –

+0

私はあなたの意味する新しい活動であるLAT1 –

答えて

0

私はと思われますgetTextStringまたはCharSequenceを返します。したがって、文字列をバンドルに入れても、ダブルとして読み取ることになります。代わりに、あなたは二重の最初に変換してください:あなたを想定しています

newActivity.putExtra("LAT", Double.parseDouble(getText(R.string.LAT1))); 
newActivity.putExtra("LNG", Double.parseDouble(getText(R.string.LNG1))); 

はすでに正しくTextView sが本当に有効な二重が含まれていることを検証しました。

+0

ありがとうございました!!あなたはそれを修正しました! –

+0

私は警告を見てください。私は私の答えで投稿しました!ありがとう@ kabuko –

+0

私はエラーがかなり明確だと思います: "キーLNGはDoubleを期待しましたが、値はjava.lang.Integerでした"。あなたはある時点で整数を入れます。 – kabuko

関連する問題