-3

my below code doesn't give any result.

list_addr = gc.getFromLocation(latitude, longitude, 5); 

even not returns null value...

it behaves like dumb.

give me solution for that.

Martin Buberl
  • 45,844
  • 25
  • 100
  • 144
LostGeek
  • 123
  • 13

2 Answers2

1

Geocoder.getFromLocations(double, double, int) either returns a result (even null is a result) or throws an exception.

Are you silently catching generic exceptions somewhere in your code?

Update:

Use this code and then check the logcat. It should give you a reason why this does not work:

    Geocoder gc = new Geocoder(getApplicationContext(), Locale.getDefault());
    try {
        List<Address> list_addr = gc.getFromLocation(40.0d, 10.0d, 5);
    } catch (IllegalArgumentException iae) {
        Log.e("Geocoder IllegalArgumentException exception: ", iae.getMessage());
    } catch (IOException ioe) {
        Log.e("Geocoder IOException exception: ", ioe.getMessage());
    }

Update2:

This turned out to be a bug in Emulator v2.2: Android; Geocoder, why do I get "the service is not available"?

Community
  • 1
  • 1
Peter Knego
  • 79,991
  • 11
  • 123
  • 154
0

try this

List<Address> addresses = new Geocoder(MyActivity.this,Locale.getDefault()).getFromLocation(latitude, longitude, 1);
Tushar Vengurlekar
  • 7,649
  • 8
  • 33
  • 48