1

I am making an android app, and need to use Google maps' reverse geocoding. The relevant code is:

  Geocoder geoCoder = new Geocoder(getApplicationContext(), Locale.getDefault());
  List<Address> matches = geoCoder.getFromLocation(latitude, longitude, 1);
  // latitude and longitude are double variables containing the coordinates.

On the first line of the code above I am getting the compiling error:

"The constructor Geocoder(Context, Locale) is undefined"

I tried googling but could not find a resolution. Thanks.

vergil corleone
  • 1,091
  • 3
  • 16
  • 34
  • 1
    check that your import is android.location.Geocoder – Blackbelt May 16 '13 at 17:42
  • @blackbelt Yep, that worked. Write as answer for points. – vergil corleone May 16 '13 at 17:45
  • I encountered a similar issue:: Geocoder geocoder = new Geocoder(this, Locale.getDefault()); ............... was giving a similar error but Geocoder geocoder = new Geocoder(MyActivity.this, Locale.getDefault()); ...... resolved my problem – Devrath Apr 15 '14 at 02:17

1 Answers1

1

The constructor Geocoder(Context, Locale) is defined. Check if you import the correct class

 android.location.Geocoder

here the documentation

Blackbelt
  • 156,034
  • 29
  • 297
  • 305