Yes, getFromLocation does sometimes return no results for no visible
reason.

I put the command within a Try....Catch and throw an exception if I
get 0 results returned.  The whole thing is then wrapped in a
countdown loop and I allow up to 3 exceptions before giving up.  It's
not pretty but it works for me (>95% of the time anyways).


Another suggestion: if you are only going to ever look at the first
result returned, don't request 10 - and certainly not 100!





On Oct 19, 5:36 pm, Tommy <droi...@gmail.com> wrote:
> Hi everyone,
>
> I am using the Geocoder.getFromLocation(lat,lon,1) and it seems that a
> lot of the time nothing gets returned to the List<Address> array
> sometimes it works as it is suppose to. Is there a better way to get
> the city/state from the lat/lon that is more reliable? the code I use
> is below:
>
> Geocoder gc = new Geocoder(this, Locale.getDefault());
>                         List<Address> addresses = null;
>
>                                         addresses = gc.getFromLocation(lat, 
> lon, 10);
>                                         cityState = 
> addresses.get(0).getLocality();
>                                         stateAbrv = 
> addresses.get(0).getAdminArea();
>
> When it doesn't work it is because addresses  is null
>
> Thanks in advance for the help,tips, and/or advice,
>
> Tommy

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to