0
From a click on the map, I take latitude and longitude and turn it into a String
address, 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 comes full of characters, as in this example:
[Address[addressLines=[0:"Rua Martins, 132 - Vila Oeste",1:"Belo Horizonte - MG",2:"Brasil"],Feature=132,admin=Minas General,sub-admin=null,locality=Belo Horizonte,Horoughfare=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 address Street number - neighborhood - country .. for example?