Ciao blackgin,
e' perche' nella main activity faccio questo:
public void onLocationChanged(Location location) {
List<Overlay> overlays = mv.getOverlays();
//List overlays = mv.getOverlays();
overlay = new MyLocationOverlay(this, mv);
overlays.add(overlay);
overlay.enableMyLocation();
String latLongString;
View inflatedView = View.inflate(this, R.layout.hit, null);
TextView myLocationText = (TextView) inflatedView.findViewById(R.id.myLocationText);
String addressString = "No address found";
if (location != null) {
double lat = location.getLatitude();
double lng = location.getLongitude();
latLongString = "Lat:" + lat + "\nLong:" + lng;
double latitude = location.getLatitude();
double longitude = location.getLongitude();
Geocoder gc = new Geocoder(this, Locale.getDefault());
try {
List<Address> addresses = gc.getFromLocation(latitude, longitude, 1);
StringBuilder sb = new StringBuilder();
if (addresses.size() > 0) {
Address address = addresses.get(0);
for (int i = 0; i < address.getMaxAddressLineIndex(); i++)
sb.append(address.getAddressLine(i)).append("\n");
sb.append(address.getLocality()).append("\n");
sb.append(address.getPostalCode()).append("\n");
sb.append(address.getCountryName());
}
addressString = sb.toString();
} catch (IOException e) {}
} else {
latLongString = "No location found";
}
Log.v(LOG_TAG, "latLong: "+latLongString);
Log.v(LOG_TAG, "add: "+addressString);
myLocationText.setText("Your Current Position is:\n" + latLongString + "\n" + addressString);
Log.v(LOG_TAG, "myLocationText: "+myLocationText);
}
Qualche consiglio?