0

I need to get address from lon lat location. I was trying with geodecoder but it doesn't work (throws Service Not Available). Is there any other solution to that problem?

santBart
  • 2,466
  • 9
  • 43
  • 66

2 Answers2

1

The geocoder is not guaranteed to exist on all devices. Couple of things to try:

  1. The documentation is not exactly clear, but it seems that if you have the Google add-ons, you should have a geocoder backend implementation. Try linking against the Google APIs for your target API level (see below) https://stackoverflow.com/a/2255592/483708

  2. In your implementation, prevent erroneous results by explicitly checking for geocoding functionality with Geocoder.isPresent() http://developer.android.com/reference/android/location/Geocoder.html#isPresent()

  3. If the above points are insufficient, you will need to use the Google Maps Web APIs to perform reverse geocoding via the web: http://code.google.com/apis/maps/documentation/geocoding/index.html#ReverseGeocoding

Also take a look at the GeoCoderPlus library referenced in this blog post
http://bricolsoftconsulting.com/perfect-geocoding-zoom-part-1/

It uses Google Maps Web APIs, but for 'forward' geocoding. You may be able to use the blog post and the included code as guidance to build your own implementation of reverse geocoding via the web.

Community
  • 1
  • 1
Theo
  • 5,963
  • 3
  • 38
  • 56
0

It seems to be a bug in the emulator running SDK 2.2. I have had the same problem. Create a 2.1 or 2.3 emulator and try your code.

znat
  • 13,144
  • 17
  • 71
  • 106
  • I cantrun it 2.1, in 2.3 the problem is the same. – santBart Jan 08 '12 at 21:32
  • Did you create a new emulator (not just changed the SDK version in an existing one)? Have you tried on a real device? If it is not an emulator problem, can you post your code? – znat Jan 08 '12 at 21:39
  • I have made emulator in 2.3. I haven't tried in real device. My code: Geocoder geocoder = new Geocoder(getApplicationContext(), Locale.getDefault()); List
    addresses = geocoder.getFromLocation(lat,lon, 1);
    – santBart Jan 08 '12 at 21:42