如何在同一项目中获得连续位置(Lat和Lng)以及位置地址



我想显示一个持续更新的Lat和long以及位置地址。

我能够收到连续的lat/lng,但无法找到位置地址。

基本上,我想把这两个结合起来:https://developer.android.com/training/location/receive-location-updates.html

https://developer.android.com/training/location/display-address.html

我怎样才能做到这一点?

谢谢。

嗨,你可以使用Geocoder类获得一个位置地址

Geocoder gcd = new Geocoder(this, Locale.getDefault());
List<Address> addresses;
String city;
try {
    addresses = gcd.getFromLocation(lat,lon, 1);
    if (addresses.size() > 0) 
        city = addresses.get(0).getLocality();
} catch (IOException e) {
    e.printStackTrace();
}