Service not Available - Geocoder Android [duplicate]

匿名 (未验证) 提交于 2019-12-03 02:06:01

问题:

This question already has an answer here:

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 = 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) 

Thanks and regards, Anass

回答1:

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



回答2:

You will get this error occasionally if the GeoCoding provider fails and is unable to geocode your location.

See these relevant posts:

Geocoder.getFromLocation throws Exception

Geocoder.getFromLocation throws IOException on Android emulator

If this is not the case, make sure you have the Internet permission in your Manifest:



回答3:

Try updating Location first. Like below

locationManager.requestLocationUpdates(bestProvider, 20000, 1, this); 

refer to here.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!