gpt4 book ai didi

android - 通过 Intent 传递纬度/经度

转载 作者:行者123 更新时间:2023-11-29 15:12:55 25 4
gpt4 key购买 nike

我收集了不同纬度和经度的位置。我想知道我是否可以将它们设置为数组字符串,例如(String lat = {“9385853.0094”,“23123123.234”)然后通过 Intent 传递它们,以便我可以在新的经纬度中显示谷歌地图中的位置 Activity 。

最佳答案

例如,您有两个名为 Maps.java 和 Routes.java 的类。

使用以下代码传递 LatLng

LatLng fromPosition = new LatLng(9385853.0094, 23123123.234 );
LatLng toPosition = new LatLng(11.145315551, 99.333455333);

Bundle args = new Bundle();
args.putParcelable("from_position", fromPosition);
args.putParcelable("to_position", toPosition);

i.putExtra("bundle", args);

Intent i= new Intent(Maps.this, Routes.class);
startActivity(i);

并在接收端使用如下代码

Bundle bundle = getIntent().getParcelableExtra("bundle");
LatLng fromPosition = bundle.getParcelable("from_position");
LatLng toPosition = bundle.getParcelable("to_position");

希望对您有所帮助!

关于android - 通过 Intent 传递纬度/经度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28572267/

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