Does Geocoder.getfromlocationname Not Work On Emulators?
Solution 1:
If your app works on a real device, then your code should be fine. Think of geocoding as a service that companies have to subscribe or buy in to for their devices. I think most of them just use Google, but they could probably use Bing or some other as well.
From the docs:
The Geocoder class requires a backend service that is not included in the core android framework. The Geocoder query methods will return an empty list if there no backend service in the platform. Use the isPresent() method to determine whether a Geocoder implementation exists.
In my experience, calling geocoder.isPresent()
from the emulator will return false, and from a real phone will return true, as long as the real phone is made by a company you've heard of.
If you want a work around/backup service, you can query the Google Maps API through HTTP just like you would from a web page. There's an example in this answer here.
Solution 2:
What API version are you testing on? There appears to be a bug in earlier Android versions Geocoder works in 1.6 but not in 2.2 emulator
Also make sure your app has INTERNET permission (I assume it does as your map shows map tiles)
I always use real devices to test location functionality as I find it much easier, and closer to real-world scenarios.
Do note that the geocoder functionality is only available on official Android devices, i.e. those with Market/Gmail/Maps etc. So a low-cost Android device without the Android Market will fail to provide geocode results.
Post a Comment for "Does Geocoder.getfromlocationname Not Work On Emulators?"