【发布时间】:2015-10-11 18:07:04
【问题描述】:
我是谷歌地图的新手,需要在 textView 中显示用户所在的国家/地区。 目前我的应用正在显示纬度、经度和地址。现在我需要国家/地区。
我已声明如下:
private LocationManager locationManager;
private Location myLocation;
在 OnCreate 下
lblAddress = (TextView) findViewById(R.id.tvAddress);
获取我使用的地址;
private String getCompleteAddressString(double LATITUDE, double LONGITUDE, int x)
{
String strAdd = "";
Geocoder geocoder = new Geocoder(this, Locale.getDefault());
try
{
List<Address> addresses = geocoder.getFromLocation(LATITUDE, LONGITUDE, 1);
if (addresses != null)
{
Address returnedAddress = addresses.get(0);
StringBuilder strReturnedAddress = new StringBuilder("");
for (int i = 0; i < returnedAddress.getMaxAddressLineIndex(); i++)
{
strReturnedAddress.append(returnedAddress.getAddressLine(i)).append("\n");
}
strAdd = strReturnedAddress.toString();
}
}
catch (Exception e)
{
lblAddress.setText("Your address cannot be determined");
}
return strAdd;
}
现在我如何以同样的方式获得国家/地区?
【问题讨论】:
-
returnedAddress.getCountryName() -
您能详细说明一下吗?对不起。
标签: java android google-maps geolocation textview