【问题标题】:Android GSon serialize double to .net compatibleAndroid Gson 序列化 double 到 .net 兼容
【发布时间】:2010-10-18 09:22:44
【问题描述】:

我有一个像这样的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 纬度 = 43802334 和 int 经度 = 24825592 p中转换后的值为:4.3802334E7和2.4825592E7

我希望双精度值没有 E7,因为 Web 服务会因此引发错误。我做错了什么,不明白为什么。你能给个建议吗?谢谢

【问题讨论】:

    标签: android double gson


    【解决方案1】:

    没关系,我只需要从地图意图发送纬度和经度作为两倍和 clikcedLocation.getLatidudeE6 /1E6

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-19
      • 2023-04-02
      相关资源
      最近更新 更多