"The geocoder class requires a backend service that is not supported in the core Android framework. The geocoder query methods will return an empty list if there no backend service in the platform."
Here we have mentioned that we need to have a backend service, but we have some suggestions on how to get this service. Some people in the Forum think we should use Google map API.
In the following two links, foreign friends also mentioned using map Api!
The documentation states: The geocoder class requires a backend service that is not supported in the core Android framework, how/Where can I obtain such a service?
It seems it's a bug in the emulator for 2.2 and there is a bug fix about it, for details
Seehttp: // code.google.com/p/android/issues/detail? Id = 8816
I have found a workaround to the issue. I used the standard Google API:
Http://code.google.com/apis/maps/documentation/geocoding/
I have created a method that requires ed a string address like "220 + Victoria + square" and returns a jsonobject with the response of the HTTP call
Public static jsonobject getlocationinfo (string address) {</P> <p> httpget = new httpget ("http://maps.google. <br/> + "com/maps/API/geocode/JSON? Address = "+ address <br/> +" Ka & sensor = false "); <br/> httpclient client = new defaulthttpclient (); <br/> httpresponse response; <br/> stringbuilder = new stringbuilder (); </P> <p> try {<br/> response = client.exe cute (httpget ); <br/> httpentity entity = response. getentity (); <br/> inputstream stream = entity. getcontent (); <br/> int B; <br/> while (B = stream. read ())! =-1) {<br/> stringbuilder. append (char) B); <br/>}< br/>} catch (clientprotocolexception e) {<br/>} catch (ioexception E) {<br/>}</P> <p> jsonobject = new jsonobject (); <br/> try {<br/> jsonobject = new jsonobject (stringbuilder. tostring (); <br/>} catch (jsonexception e) {<br/> // todo auto-generated Catch Block <br/> E. printstacktrace (); <br/>}</P> <p> return jsonobject; <br/>}
After executing this, another method converts that jsonobject into a geopoint.
Public static geopoint getgeopoint (jsonobject) {</P> <p> double Lon = new double (0); <br/> double lat = new double (0 ); </P> <p> try {</P> <p> Lon = (jsonarray) jsonobject. get ("Results ")). getjsonobject (0) <br/>. getjsonobject ("Geometry "). getjsonobject ("location") <br/>. getdouble ("LNG"); </P> <p> lat = (jsonarray) jsonobject. get ("Results ")). getjsonobject (0) <br/>. getjsonobject ("Geometry "). getjsonobject ("location") <br/>. getdouble ("Lat"); </P> <p >}catch (jsonexception e) {<br/> // todo auto-generated Catch Block <br/> E. printstacktrace (); <br/>}</P> <p> return New geopoint (INT) (LAT * 1e6), (INT) (Lon * 1e6 )); </P> <p>}
However this solution is extremely nasty and coupled ..
PS. You shoshould add
<Uses-library Android: Name = "com. Google. Android. Maps"> </uses-library>
To androidmanifest. xml or application cocould not find geopoint class.
By the way, we recommend an android map development introductory article:
Http://mobiforge.com/developing/story/using-google-maps-android