-4
05-08 11:04:12.336: E/AndroidRuntime(678): FATAL EXCEPTION: main

05-08 11:04:12.336: E/AndroidRuntime(678): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android/com.android.Calendar_googleActivity}: android.os.NetworkOnMainThreadException

05-08 11:04:12.336: E/AndroidRuntime(678):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)

05-08 11:04:12.336: E/AndroidRuntime(678):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)

05-08 11:04:12.336: E/AndroidRuntime(678):  at android.app.ActivityThread.access$600(ActivityThread.java:123)

05-08 11:04:12.336: E/AndroidRuntime(678):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)

05-08 11:04:12.336: E/AndroidRuntime(678):  at android.os.Handler.dispatchMessage(Handler.java:99)

05-08 11:04:12.336: E/AndroidRuntime(678):  at android.os.Looper.loop(Looper.java:137)

05-08 11:04:12.336: E/AndroidRuntime(678):  at android.app.ActivityThread.main(ActivityThread.java:4424)

05-08 11:04:12.336: E/AndroidRuntime(678):  at java.lang.reflect.Method.invokeNative(Native Method)

05-08 11:04:12.336: E/AndroidRuntime(678):  at java.lang.reflect.Method.invoke(Method.java:511)

05-08 11:04:12.336: E/AndroidRuntime(678):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)

05-08 11:04:12.336: E/AndroidRuntime(678):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)

05-08 11:04:12.336: E/AndroidRuntime(678):  at dalvik.system.NativeStart.main(Native Method)

05-08 11:04:12.336: E/AndroidRuntime(678): Caused by: android.os.NetworkOnMainThreadException

05-08 11:04:12.336: E/AndroidRuntime(678):  at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1099)

05-08 11:04:12.336: E/AndroidRuntime(678):  at java.net.InetAddress.lookupHostByName(InetAddress.java:391)

05-08 11:04:12.336: E/AndroidRuntime(678):  at java.net.InetAddress.getAllByNameImpl(InetAddress.java:242)

05-08 11:04:12.336: E/AndroidRuntime(678):  at java.net.InetAddress.getAllByName(InetAddress.java:220)

05-08 11:04:12.336: E/AndroidRuntime(678):  at libcore.net.http.HttpConnection.<init>(HttpConnection.java:71)

05-08 11:04:12.336: E/AndroidRuntime(678):  at libcore.net.http.HttpConnection.<init>(HttpConnection.java:50)

05-08 11:04:12.336: E/AndroidRuntime(678):  at libcore.net.http.HttpConnection$Address.connect(HttpConnection.java:351)

05-08 11:04:12.336: E/AndroidRuntime(678):  at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:86)

05-08 11:04:12.336: E/AndroidRuntime(678):  at libcore.net.http.HttpConnection.connect(HttpConnection.java:128)

05-08 11:04:12.336: E/AndroidRuntime(678):  at libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:308)

05-08 11:04:12.336: E/AndroidRuntime(678):  at libcore.net.http.HttpsURLConnectionImpl$HttpsEngine.makeSslConnection(HttpsURLConnectionImpl.java:460)

05-08 11:04:12.336: E/AndroidRuntime(678):  at libcore.net.http.HttpsURLConnectionImpl$HttpsEngine.connect(HttpsURLConnectionImpl.java:432)

05-08 11:04:12.336: E/AndroidRuntime(678):  at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:282)

05-08 11:04:12.336: E/AndroidRuntime(678):  at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:232)

05-08 11:04:12.336: E/AndroidRuntime(678):  at libcore.net.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:80)

05-08 11:04:12.336: E/AndroidRuntime(678):  at libcore.net.http.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:164)

05-08 11:04:12.336: E/AndroidRuntime(678):  at com.google.api.client.http.javanet.NetHttpRequest.execute(NetHttpRequest.java:88)

05-08 11:04:12.336: E/AndroidRuntime(678):  at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:814)

05-08 11:04:12.336: E/AndroidRuntime(678):  at com.google.api.client.googleapis.json.GoogleJsonResponseException.execute(GoogleJsonResponseException.java:182)

05-08 11:04:12.336: E/AndroidRuntime(678):  at com.google.api.client.googleapis.services.GoogleClient.executeUnparsed(GoogleClient.java:115)

05-08 11:04:12.336: E/AndroidRuntime(678):  at com.google.api.client.http.json.JsonHttpRequest.executeUnparsed(JsonHttpRequest.java:112)

05-08 11:04:12.336: E/AndroidRuntime(678):  at com.google.api.services.calendar.Calendar$CalendarList$List.execute(Calendar.java:510)

05-08 11:04:12.336: E/AndroidRuntime(678):  at com.android.Calendar_googleActivity.onAuthToken(Calendar_googleActivity.java:267)

05-08 11:04:12.336: E/AndroidRuntime(678):  at com.android.Calendar_googleActivity.gotAccount(Calendar_googleActivity.java:118)

05-08 11:04:12.336: E/AndroidRuntime(678):  at com.android.Calendar_googleActivity.onCreate(Calendar_googleActivity.java:108)

05-08 11:04:12.336: E/AndroidRuntime(678):  at android.app.Activity.performCreate(Activity.java:4465)

05-08 11:04:12.336: E/AndroidRuntime(678):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)

05-08 11:04:12.336: E/AndroidRuntime(678):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)

05-08 11:04:12.336: E/AndroidRuntime(678):  ... 11 more
4

1 に答える 1

2
 Caused by: android.os.NetworkOnMainThreadException

ネットワーク操作が遅れると、UIラグが発生し、アプリケーションがエラーに応答しなくなる可能性があるため、UIスレッドでネットワークを実行しないように常に警告されています。

最近のリリースでは、上記のプロアクティブなエラーにより、実際に「それを回避する」ことを禁止されています。

したがって、ネットワークの使用をUIスレッドから外すと、すべて設定されているはずです。ここでそれを行う方法について説明する必要はありません。ドキュメントと以前の質問で十分に説明されています。

于 2012-05-08T04:37:44.990 に答える