¿Por qué Geocoder de Google Maps está devolviendo el carácter japonés?
Tengo un método con cuerpo como este:
Address address = new Geocoder(context).getFromLocation(latitude, longitude, 5).get(0);
return address.getThoroughfare() + ", " + address.getSubThoroughfare() + ", " + address.getSubLocality();
Cuando imprimo el resultado, el valor deaddress.getSubLocality()
muestra una cadena en japonés.
¿Por qué esta felicidad?
¿Y cómo puedo solucionar esto?
¡Gracias!
EDITAR
Mi proyecto de ejemplo completo:
public class MainActivity extends Activity implements View.OnClickListener {
EditText ed1, ed2;
TextView tv1;
Button bt1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ed1 = (EditText) findViewById(R.id.ed1);
ed2 = (EditText) findViewById(R.id.ed2);
tv1 = (TextView) findViewById(R.id.tv1);
bt1 = (Button) findViewById(R.id.bt1);
ed1.setText("-23.50282");
ed2.setText("-46.84905");
bt1.setOnClickListener(this);
}
public static String getAddressFromLocation(Context context, Double latitude, Double longitude) throws IOException {
Address address = new Geocoder(context, Locale.ENGLISH).getFromLocation(latitude, longitude, 5).get(0);
return address.getThoroughfare() + ", " + address.getSubThoroughfare() + ", " + address.getSubLocality() + " - " + address.getAdminArea();
}
@Override
public void onClick(View v) {
String address = "Street";
if (v.getId() == R.id.bt1) {
try {
address = getAddressFromLocation(this, Double.parseDouble(ed1.getText().toString()), Double.parseDouble(ed2.getText().toString()));
} catch (IOException e) {
e.printStackTrace();
}
tv1.setText(address);
}
}
}