I am trying to get address of a location by passing latitude and longitude.But the address is always null.
Here is my code..
@Override
public void onLocationChanged(Location location) {
// Called when a new location is found by the network location provider.
if (location != null){
Geocoder geocoder = new Geocoder(Start_service.this.getBaseContext(), Locale.getDefault());
// lat,lng, your current location
try {
lati= location.getLatitude();
longi=location.getLongitude();
speed=location.getSpeed();
addresses =geocoder.getFromLocation(location.getLatitude(),location.getLongitude(), 1);
System.out.println("Address is"+ addresses);
}
catch (IOException e) {
System.out.println(e);
e.printStackTrace();
}