I have a little problem with the geocoder to get latitude and lontitude from an address :
This is my code:
for (Garage g : XMLGarage) {
List<Address> address;
address = coder.getFromLocationName(
g.getAddress(), 5);
if (address != null) {
Address location = address.get(0);
g.setLatitude(location.getLatitude());
g.setLongitude(location.getLongitude());
...
The error is :
08-18 14:28:56.026: WARN/System.err(359): java.io.IOException: Service not Available
08-18 14:28:56.026: WARN/System.err(359): at
android.location.Geocoder.getFromLocationName(Geocoder.java:178)
08-18 14:28:56.026: WARN/System.err(359): at
com.amt.android.garage.Garage.postData(Garage.java:269)
08-18 14:28:56.026: WARN/System.err(359): at
com.amt.android.garage.GarageForm$2.onClick(GarageForm.java:86)
08-18 14:28:56.026: WARN/System.err(359): at
android.view.View.performClick(View.java:2485)
08-18 14:28:56.026: WARN/System.err(359): at
android.view.View$PerformClick.run(View.java:9080)
08-18 14:28:56.036: WARN/System.err(359): at
android.os.Handler.handleCallback(Handler.java:587)
08-18 14:28:56.036: WARN/System.err(359): at
android.os.Handler.dispatchMessage(Handler.java:92)
08-18 14:28:56.036: WARN/System.err(359): at
android.os.Looper.loop(Looper.java:130)
08-18 14:28:56.036: WARN/System.err(359): at
android.app.ActivityThread.main(ActivityThread.java:3683)
08-18 14:28:56.036: WARN/System.err(359): at
java.lang.reflect.Method.invokeNative(Native Method)
08-18 14:28:56.036: WARN/System.err(359): at
java.lang.reflect.Method.invoke(Method.java:507)
08-18 14:28:56.036: WARN/System.err(359): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
08-18 14:28:56.046: WARN/System.err(359): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
08-18 14:28:56.046: WARN/System.err(359): at dalvik.system.NativeStart.main(Native
Method)
There is a problem recently with android devices and the geocoder not working: http://code.google.com/p/android/issues/detail?id=38009
A reboot seems to fix the issue