从坐标获取位置

NiV*_*VeR 7 android android-location

我给出了纬度和经度的坐标,我想用那些制作一个位置对象.没有一个构造函数需要双倍来创建一个位置,所以我尝试这样:

 Location l = null;
 l.setLatitude(lat);
 l.setLongitude(lon);
Run Code Online (Sandbox Code Playgroud)

但它崩溃了.任何不同的想法?

小智 14

只需使用新位置创建一个新位置("reverseGeocoded"); 像这样

GeoPoint newCurrent = new GeoPoint(59529200, 18071400);
        Location current = new Location("reverseGeocoded");
        current.setLatitude(newCurrent.getLatitudeE6() / 1e6);
        current.setLongitude(newCurrent.getLongitudeE6() / 1e6);
        current.setAccuracy(3333);
        current.setBearing(333);
Run Code Online (Sandbox Code Playgroud)