Android 通过lng/lat和额外管束不起作用

Android 通过lng/lat和额外管束不起作用,android,map,Android,Map,我正在创建一个包含三个主要活动的项目(让我们称之为活动1、2和3)。 在活动1中,我额外传递包中的数字 newActivity.putExtra("LAT", getText(R.string.LAT1)); newActivity.putExtra("LNG", getText(R.string.LNG1)); 然后,在第二个例子中,我得到如下结果: double Lata; double Lnga; //in onCreate.. Bundle extr

我正在创建一个包含三个主要活动的项目(让我们称之为活动1、2和3)。 在活动1中,我额外传递包中的数字

newActivity.putExtra("LAT", getText(R.string.LAT1));
newActivity.putExtra("LNG", getText(R.string.LNG1));
然后,在第二个例子中,我得到如下结果:

     double Lata;
    double Lnga;

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

        Lata = extras.getDouble("LAT");
        Lnga = extras.getDouble("LNG");
然后,我将它们传递给第三个活动,如下所示:

newActivity.putExtra("LAT",Lata);
newActivity.putExtra("LNG",Lnga);
最后,在第三个活动中:

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;
 }
}

我怀疑
getText
返回一个
String
或一个
CharSequence
,因此您将一个字符串放入捆绑包中,但将其作为双精度字符串读取。相反,请确保先将其转换为双精度:

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

这是假设您已经正确验证了
TextView
s确实包含有效的double。

启动新活动时是否确实附加了捆绑包?getText(R.string.LAT1),这行的作用是什么?我在string.xml文件中有一个名为LAT1@Tony你指的是哪项新活动?请看我收到的警告。我已经在我的答案中发布了它!!谢谢@kabukoI,我认为错误很明显:“Key应该是Double,但value是java.lang.Integer”。您在某个点输入了一个整数。问题可能在这里??地质点中心=新的地质点(Double.valueOf(Latc*1E6).intValue(),Double.valueOf(Lngc*1E6.intValue());请阅读实际堆栈跟踪并查看:在kostas.menu.athensmumbers.museum\u item.onCreate(museum\u item.java:40)。您只包含了代码片段,所以其他人很难确切地知道代码是什么。第40行是Lata=extras.getDouble(“LAT”);
newActivity.putExtra("LAT", Double.parseDouble(getText(R.string.LAT1)));
newActivity.putExtra("LNG", Double.parseDouble(getText(R.string.LNG1)));