Hm, I like your idea of putting it in a try catch....Yeah I only did 10 as a test to see if it would return something more often. If I still have issues I'll give the Yahoo API a try. Thanks to EVERYONE for your input/advice!
Tommy Android Mobile Phone Application Developer Database Administrator .net Web Specialist -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Spiral123 Sent: Wednesday, October 20, 2010 8:24 AM To: Android Developers Subject: [android-developers] Re: Android Geocoder Issues 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 <[email protected]> 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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

