我通过 xml 解析向我的应用程序添加了版本检查。
但是当我尝试执行它时,它会在我粘贴在那里的异常中运行:
11-03 19:21:36.809: E/AndroidRuntime(16531): FATAL EXCEPTION: main
11-03 19:21:36.809: E/AndroidRuntime(16531): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.lookedpath.firstlesson/com.lookedpath.firstlesson.Update}: android.os.NetworkOnMainThreadException
11-03 19:21:36.809: E/AndroidRuntime(16531): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2099)
11-03 19:21:36.809: E/AndroidRuntime(16531): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2210)
11-03 19:21:36.809: E/AndroidRuntime(16531): at android.app.ActivityThread.access$600(ActivityThread.java:142)
11-03 19:21:36.809: E/AndroidRuntime(16531): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1208)
11-03 19:21:36.809: E/AndroidRuntime(16531): at android.os.Handler.dispatchMessage(Handler.java:99)
11-03 19:21:36.809: E/AndroidRuntime(16531): at android.os.Looper.loop(Looper.java:137)
11-03 19:21:36.809: E/AndroidRuntime(16531): at android.app.ActivityThread.main(ActivityThread.java:4931)
11-03 19:21:36.809: E/AndroidRuntime(16531): at java.lang.reflect.Method.invokeNative(Native Method)
11-03 19:21:36.809: E/AndroidRuntime(16531): at java.lang.reflect.Method.invoke(Method.java:511)
11-03 19:21:36.809: E/AndroidRuntime(16531): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
11-03 19:21:36.809: E/AndroidRuntime(16531): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:558)
11-03 19:21:36.809: E/AndroidRuntime(16531): at dalvik.system.NativeStart.main(Native Method)
11-03 19:21:36.809: E/AndroidRuntime(16531): Caused by: android.os.NetworkOnMainThreadException
11-03 19:21:36.809: E/AndroidRuntime(16531): at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1117)
11-03 19:21:36.809: E/AndroidRuntime(16531): at java.net.InetAddress.lookupHostByName(InetAddress.java:385)
11-03 19:21:36.809: E/AndroidRuntime(16531): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236)
11-03 19:21:36.809: E/AndroidRuntime(16531): at java.net.InetAddress.getAllByName(InetAddress.java:214)
11-03 19:21:36.809: E/AndroidRuntime(16531): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:137)
11-03 19:21:36.809: E/AndroidRuntime(16531): at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
11-03 19:21:36.809: E/AndroidRuntime(16531): at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
11-03 19:21:36.809: E/AndroidRuntime(16531): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360)
11-03 19:21:36.809: E/AndroidRuntime(16531): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
11-03 19:21:36.809: E/AndroidRuntime(16531): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
11-03 19:21:36.809: E/AndroidRuntime(16531): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
11-03 19:21:36.809: E/AndroidRuntime(16531): at com.lookedpath.firstlesson.XMLParser.getXmlFromUrl(XMLParser.java:35)
11-03 19:21:36.809: E/AndroidRuntime(16531): at com.lookedpath.firstlesson.Update.<init>(Update.java:24)
11-03 19:21:36.809: E/AndroidRuntime(16531): at java.lang.Class.newInstanceImpl(Native Method)
11-03 19:21:36.809: E/AndroidRuntime(16531): at java.lang.Class.newInstance(Class.java:1319)
11-03 19:21:36.809: E/AndroidRuntime(16531): at android.app.Instrumentation.newActivity(Instrumentation.java:1053)
11-03 19:21:36.809: E/AndroidRuntime(16531): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2090)
11-03 19:21:36.809: E/AndroidRuntime(16531): ... 11 more
您可以使用 GitHub 获取 Eclipse 项目: https ://github.com/LookedPath/lookedpath_android_applications/tree/FirstApp/PrimaLezione
我应该怎么办?