java.io.IOException运行我的android程序时找不到服务

时间:2013-03-07 08:01:47

标签: android ioexception geocode

当我运行我的android项目时,我的一个用于地理编码的类显示了一个io异常,比如服务不可用我无法找到这里的错误,请有人帮我解决这个问题

我的班级

String addressInput  = "Santa Clara";

geocoder = new Geocoder(Find_Tab_MainActivity.this);
    List<Address> address;

    address = geocoder.getFromLocationName(addressInput,5);
    if (address == null) {
        alert.showAlertDialog(Find_Tab_MainActivity.this, "Places Error",
                              "Sorry error occured.",
                              false);
    }
    else{
        Address location = address.get(0);
        latitude = location.getLatitude();
        longitude = location.getLongitude();

        System.out.println("radius:");
        nearPlaces = googlePlaces.Keywordsearch(latitude,longitude,radius+40000,"parking",type);

logcat的

   03-07 12:55:09.752: D/Your Location(3625): latitude:37.422005, longitude: -122.084095
    03-07 12:55:09.812: W/System.err(3625): java.io.IOException: Service not Available
    03-07 12:55:09.862: W/System.err(3625):     at android.location.Geocoder.getFromLocationName(Geocoder.java:178)
    03-07 12:55:09.872: W/System.err(3625):     at com.kodspider.parkon.Find_Tab_MainActivity$LoadPlaces.doInBackground(Find_Tab_MainActivity.java:174)
    03-07 12:55:09.872: W/System.err(3625):     at com.kodspider.parkon.Find_Tab_MainActivity$LoadPlaces.doInBackground(Find_Tab_MainActivity.java:1)
    03-07 12:55:09.872: W/System.err(3625):     at android.os.AsyncTask$2.call(AsyncTask.java:185)
    03-07 12:55:09.872: W/System.err(3625):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
    03-07 12:55:09.872: W/System.err(3625):     at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    03-07 12:55:09.872: W/System.err(3625):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
    03-07 12:55:09.872: W/System.err(3625):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
    03-07 12:55:09.872: W/System.err(3625):     at java.lang.Thread.run(Thread.java:1019)
    03-07 12:55:10.042: D/AndroidRuntime(3625): Shutting down VM
    03-07 12:55:10.042: W/dalvikvm(3625): threadid=1: thread exiting with uncaught exception (group=0x40015560)
    03-07 12:55:10.052: E/AndroidRuntime(3625): FATAL EXCEPTION: main
    03-07 12:55:10.052: E/AndroidRuntime(3625): java.lang.NullPointerException
    03-07 12:55:10.052: E/AndroidRuntime(3625):     at com.kodspider.parkon.Find_Tab_MainActivity$LoadPlaces.onPostExecute(Find_Tab_MainActivity.java:208)
    03-07 12:55:10.052: E/AndroidRuntime(3625):     at com.kodspider.parkon.Find_Tab_MainActivity$LoadPlaces.onPostExecute(Find_Tab_MainActivity.java:1)
    03-07 12:55:10.052: E/AndroidRuntime(3625):     at android.os.AsyncTask.finish(AsyncTask.java:417)
    03-07 12:55:10.052: E/AndroidRuntime(3625):     at android.os.AsyncTask.access$300(AsyncTask.java:127)
    03-07 12:55:10.052: E/AndroidRuntime(3625):     at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:429)
    03-07 12:55:10.052: E/AndroidRuntime(3625):     at android.os.Handler.dispatchMessage(Handler.java:99)
    03-07 12:55:10.052: E/AndroidRuntime(3625):     at android.os.Looper.loop(Looper.java:130)
    03-07 12:55:10.052: E/AndroidRuntime(3625):     at android.app.ActivityThread.main(ActivityThread.java:3683)
    03-07 12:55:10.052: E/AndroidRuntime(3625):     at java.lang.reflect.Method.invokeNative(Native Method)
    03-07 12:55:10.052: E/AndroidRuntime(3625):     at java.lang.reflect.Method.invoke(Method.java:507)
    03-07 12:55:10.052: E/AndroidRuntime(3625):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
    03-07 12:55:10.052: E/AndroidRuntime(3625):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
    03-07 12:55:10.052: E/AndroidRuntime(3625):     at dalvik.system.NativeStart.main(Native Method)
    03-07 12:55:11.892: I/Process(3625): Sending signal. PID: 3625 SIG: 9

1 个答案:

答案 0 :(得分:8)

也重启你的设备(我遇到了同样的问题)但this链接节省了我的时间。

http://code.google.com/p/android/issues/detail?id=38009