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

标签 android google-maps listview android-intent latitude-longitude

我收集了不同纬度和经度的位置。 我想知道我是否可以将它们设置为数组字符串,例如(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/

相关文章:

javascript - 谷歌地图和引导标签

android - 支持独立第三方对 Android 应用程序进行本地化;应用 APK 之外的本地化数据

java - 按钮点击不起作用 : button does nothing

android - 带 Google map 的 PhoneGap/Android 应用程序的域白名单

Android map 标记仅在缩放更改后显示在 map 上

android - 水平滑动不同的 ListView

java - 在列表项上滑动 Action ?

java - 具有相同父类(super class)的子对象列表的列表

android - 专门使用 GraphQl 解析 JSON 数据

android - 如何判断 Android 重复闹钟的年龄?