如何在同一项目中获取连续位置(纬度和经度)以及位置地址?

How to get continuous Location (Lat and Lng) along with location address in same project?

我想显示纬度和经度的持续更新以及位置地址。

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

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

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

我怎样才能做到这一点?

谢谢。

您好,您可以使用 Geocoder 获取位置地址 class

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