Android GSon 序列化双精度以兼容 .net
我有一个像这样的 pojo:
public class LocationPoint {
protected double la;
protected double lo;
public double getLat() {
return la;
}
public void setLat(double value) {
this.la = value;
}
public double getLong() {
return lo;
}
public void setLong(double value) {
this.lo = value;
}
}
场景: 在 MapView 活动上执行某些操作后,我回到名为 id 的活动
if (resultCode == RESULT_OK) {
int latitude = data.getIntExtra("Latitude", 0);
int longitude = data.getIntExtra("Longitude", 0);
if (latitude!=0 && longitude!=0)
{
LocationPoint p = new LocationPoint();
p.setLat((double) latitude);
p.setLong((double) longitude);
}
int latitude = 43802334 和 int longitude = 24825592 p 中的转换值是:4.3802334E7 和 2.4825592E7
我希望 double 值不包含 E7,因为 Web 服务会因此引发错误。我做错了什么并且不明白为什么。你能给个建议吗?谢谢
I have an pojo like this:
public class LocationPoint {
protected double la;
protected double lo;
public double getLat() {
return la;
}
public void setLat(double value) {
this.la = value;
}
public double getLong() {
return lo;
}
public void setLong(double value) {
this.lo = value;
}
}
The scenario:
After doing something on a MapView activity I get back to the activity that called id
if (resultCode == RESULT_OK) {
int latitude = data.getIntExtra("Latitude", 0);
int longitude = data.getIntExtra("Longitude", 0);
if (latitude!=0 && longitude!=0)
{
LocationPoint p = new LocationPoint();
p.setLat((double) latitude);
p.setLong((double) longitude);
}
The int latitude = 43802334 and int longitude = 24825592
The converted values in p are: 4.3802334E7 and 2.4825592E7
I want the double value to be without E7, because the web service throws an error because of it. I am doing something wrong and can't understan why. Can you give an advice ? Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
没关系,我只需从地图意图发送纬度和经度作为 double 和 as
clikcedLocation.getLatidudeE6 / 1E6
Never mind, I just had to send from map intent the latitude and longitude as double and as
clikcedLocation.getLatidudeE6 / 1E6