Javier Sivianes Javier Sivianes - 11 months ago 72
Android Question

How to extract location attributes using Geocoder?

When I try to get default locale it returns "zz_ZZ":

countryCode: "ZZ"
languageCode: "zz"

Code is:

private String getAddressFromLocation(Location location) {

Geocoder geoCoder = new Geocoder(this.getApplicationContext(), Locale.getDefault());
List<Address> matches = null;
try {
matches = geoCoder.getFromLocation(location.getLatitude(), location.getLongitude(), 1);
Address bestMatch = (matches.isEmpty() ? null : matches.get(0) );

if (bestMatch != null){
String fullAddress = bestMatch.getAddressLine(0);
for (int i = 1; i <= bestMatch.getMaxAddressLineIndex(); i++){
fullAddress += ", " + bestMatch.getAddressLine(i);
return fullAddress;
return Constants.EMPTY_STRING;

} catch (IOException e) {
ACRA.getErrorReporter().handleSilentException(new MyGeoLocationAddressException(TAG + " ERROR CREATING ADDRESS - " + e.getMessage()));
return Constants.EMPTY_STRING;

Do I need to setDefaultLocale? What does ZZ_zz mean?

Second problem is:

If I use the "ZZ_zz" default locale, I don't get any address but if I use:


I get the exact address.

Answer Source

ZZ_zz is the identifier for the Accented English locale and is mostly used for finding missing translations in your app.

I don't think there's a best practice on how to handle accented english, but treating it as english would probably be the best option.