通过检索 Place 对象,您可以获得关联的 Locale 对象:
Locale locale = place.getLocale();
使用此 Locale 对象,您可以通过以下方式获取国家/地区代码:
locale.getCountry();
以及国家名称:
locale.getDisplayCountry();
您可以在文档中查看更多可用的方法:http://developer.android.com/reference/java/util/Locale.html http://developer.android.com/reference/java/util/Locale.html
EDIT :
如果 Place 对象中的 Locale 为 null,您可以使用 Geocoder 从 GPS 坐标获取信息:
LatLng coordinates = place.getLatLng(); // Get the coordinates from your place
Geocoder geocoder = new Geocoder(this, Locale.getDefault());
List<Address> addresses = geocoder.getFromLocation(
coordinates.latitude,
coordinates.longitude,
1); // Only retrieve 1 address
Address address = addresses.get(0);
然后你就可以调用这些方法来获取你想要的信息
address.getCountryCode();
address.getCountryName();
Address 对象的更多方法:http://developer.android.com/reference/android/location/Address.html http://developer.android.com/reference/android/location/Address.html
请注意,应在后台线程上调用地理编码器方法,以免阻塞 UI,并且也可能无法检索到答案。