我创建了一个与 Web 服务交互的 android 应用程序。
我收到以下错误:
01-29 10:50:09.879: E/AndroidRuntime(12860): java.lang.RuntimeException: Unable to start activity ComponentInfo{aid.assistant233/aid.assistant233.AidAssistant233Activity}: java.lang.NumberFormatException:
01-29 10:50:09.879: E/AndroidRuntime(12860): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
01-29 10:50:09.879: E/AndroidRuntime(12860): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
01-29 10:50:09.879: E/AndroidRuntime(12860): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
01-29 10:50:09.879: E/AndroidRuntime(12860): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
01-29 10:50:09.879: E/AndroidRuntime(12860): at android.os.Handler.dispatchMessage(Handler.java:99)
01-29 10:50:09.879: E/AndroidRuntime(12860): at android.os.Looper.loop(Looper.java:130)
01-29 10:50:09.879: E/AndroidRuntime(12860): at android.app.ActivityThread.main(ActivityThread.java:3691)
01-29 10:50:09.879: E/AndroidRuntime(12860): at java.lang.reflect.Method.invokeNative(Native Method)
01-29 10:50:09.879: E/AndroidRuntime(12860): at java.lang.reflect.Method.invoke(Method.java:507)
01-29 10:50:09.879: E/AndroidRuntime(12860): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907)
01-29 10:50:09.879: E/AndroidRuntime(12860): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:665)
01-29 10:50:09.879: E/AndroidRuntime(12860): at dalvik.system.NativeStart.main(Native Method)
01-29 10:50:09.879: E/AndroidRuntime(12860): Caused by: java.lang.NumberFormatException:
01-29 10:50:09.879: E/AndroidRuntime(12860): at org.apache.harmony.luni.util.FloatingPointParser.parseDouble(FloatingPointParser.java:267)
01-29 10:50:09.879: E/AndroidRuntime(12860): at java.lang.Double.parseDouble(Double.java:318)
01-29 10:50:09.879: E/AndroidRuntime(12860): at aid.assistant233.AidAssistant233Activity.SaveMapsToLocalDB(AidAssistant233Activity.java:1149)
01-29 10:50:09.879: E/AndroidRuntime(12860): at aid.assistant233.AidAssistant233Activity.UpdateApplicationData(AidAssistant233Activity.java:1060)
01-29 10:50:09.879: E/AndroidRuntime(12860): at aid.assistant233.AidAssistant233Activity.UpdateFromServer(AidAssistant233Activity.java:480)
01-29 10:50:09.879: E/AndroidRuntime(12860): at aid.assistant233.AidAssistant233Activity.onCreate(AidAssistant233Activity.java:212)
01-29 10:50:09.879: E/AndroidRuntime(12860): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
01-29 10:50:09.879: E/AndroidRuntime(12860): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
01-29 1
0:50:09.879: E/AndroidRuntime(12860): ... 11 更多
我认为主要问题与以下有关:
01-29 10:50:09.879: E/AndroidRuntime(12860): Caused by: java.lang.NumberFormatException:
01-29 10:50:09.879: E/AndroidRuntime(12860): at org.apache.harmony.luni.util.FloatingPointParser.parseDouble(FloatingPointParser.java:267)
01-29 10:50:09.879: E/AndroidRuntime(12860): at java.lang.Double.parseDouble(Double.java:318)
相关代码是这样的:
for (int i = 0; i < dati.getLength(); i++) {
Element element = (Element) dati.item(i);
localDB.insertMap(XmlElemValue(element, "Title"), Double.parseDouble(XmlElemValue(element, "Latitude")), // line 1149
Double.parseDouble(XmlElemValue(element, "Longitude")), Integer.parseInt(XmlElemValue(element, "MetriDistanza")),
Integer.parseInt(XmlElemValue(element, "MinutiIntervalloControllo")));
}
webservice返回的xml中的标签纬度为:
<Latitude>43.5729</Latitude>