通过GPS坐标来活动 [英] passing GPS coordinates to activity

查看:110
本文介绍了通过GPS坐标来活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想经度和纬度的变量传递到了谷歌地图的片段另一项活动。到目前为止,我已经成功地做​​到这一点。

I am trying to pass longitude and latitude variables into another activity for the Google maps fragment. So far I have managed to do this

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

我如何收到的其他活动?

How do I receive it in the other activity?

推荐答案

提供有关类似键

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

和MAIN2活动

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

这篇关于通过GPS坐标来活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆