From a click on the map, I get the latitude and longitude and transform it into an Address String, below the code I use:
private List<android.location.Address> addresses;
@Override
public void onMapClick(LatLng latLng) {
if (mapclickActivate) {
mappoint = latLng;
Geocoder geocoder = new Geocoder(activity, Locale.getDefault());
try {
addresses = geocoder.getFromLocation(mappoint.latitude, mappoint.longitude, 1);
} catch (IOException e) {
e.printStackTrace();
}
if (mappoint != null) {
Bundle bundle = new Bundle();
bundle.putString("address", String.valueOf(addresses));
Intent sendIntent = new Intent(activity, PointInserirActivity.class);
sendIntent.putExtras(bundle);
activity.startActivity(sendIntent);
}
}
}
But the address is full of characters, as in this example:
[Address [addressLines = [0: "Rua Martins, 132 - Vila Oeste", 1: "Belo Horizon - MG ", 2:" Brazil "], feature = 132, admin = Mines General, sub-admin = null, locality = Belo Horizonte, thoroughfare = Rua Pinto Martins, postalCode = 30532, countryCode = BR, countryName = Brazil, hasLatitude = true, latitude = -19.9398299, hasLongitude = true, longitude = -44.0038374, phone = null, url = null, extras = null]]
How can I get only the street address, number - Neighborhood - Country .. for example?