gpt4 book ai didi

java - 将 GPS 坐标传递给 Activity

转载 作者:行者123 更新时间:2023-11-29 21:38:19 24 4
gpt4 key购买 nike

我正在尝试将经度和纬度变量传递到 Google map fragment 的另一个 Activity 中。到目前为止,我已经设法做到这一点

Intent i = new Intent(Main.this, Main2.class);
i.putExtra(Double.toString(gettextLong), xLocation.getLongitude());
i.putExtra(Double.toString(gettextLat), xLocation.getLatitude());'

我如何在其他 Activity 中收到它?

最佳答案

给出相关的key like

Intent i = new Intent(Main.this, Main2.class);
i.putExtra("longitude", xLocation.getLongitude());
i.putExtra("latitude", xLocation.getLatitude());

并在 Main2 Activity 中

Bundle extras = getIntent().getExtras(); 
if(extras !=null && extras.getDouble("latitude") != null && extras.getDouble("longitude") != null) {
double lat = extras.getDouble("latitude");
double lng = extras.getDouble("longitude");
}

关于java - 将 GPS 坐标传递给 Activity ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17787086/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com