Search code examples
javaandroideclipsegoogle-geocoder

Geocoder forceclose


I have this application that is supposed to get the address from longitude and latitude but it keeps forceclosing when I push the button to call the information.

Logcat Error:

10-25 14:33:51.802: ERROR/AndroidRuntime(11166):     at http.www.hotapp.com.timeandlocation.LocationManagerHelper.getAddress(LocationManagerHelper.java:51)

My Geocoder Code

public static boolean getAddress(){
  Geocoder geoCoder = new Geocoder(context);
  try {
    geoCoder.getFromLocation(getLatitude(), getLongitude(), 0);
  } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
  }
  return true;
}

The logcat error is saying that the error is on the line with new Geocoder. please help.


Solution

  • The context that you are using is probably wrong, it should be that of the calling Activity.