[置顶] android.os.NetworkOnMainThreadException exception

android.os.NetworkOnMainThreadException
11-06 18:13:40.230: W/System.err(26935):  at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1128)
11-06 18:13:40.232: W/System.err(26935):  at libcore.net.http.HttpConnection.<init>(HttpConnection.java:70)
11-06 18:13:40.233: W/System.err(26935):  at libcore.net.http.HttpConnection.<init>(HttpConnection.java:50)
11-06 18:13:40.234: W/System.err(26935):  at libcore.net.http.HttpConnection$Address.connect(HttpConnection.java:340)
11-06 18:13:40.235: W/System.err(26935):  at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:87)
11-06 18:13:40.235: W/System.err(26935):  at libcore.net.http.HttpConnection.connect(HttpConnection.java:128)
11-06 18:13:40.235: W/System.err(26935):  at libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:316)
11-06 18:13:40.236: W/System.err(26935):  at libcore.net.http.HttpEngine.connect(HttpEngine.java:311)
11-06 18:13:40.238: W/System.err(26935):  at libcore.net.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:81)
11-06 18:13:40.238: W/System.err(26935):  at libcore.net.http.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:205)

 

是因为 调用http的请求的线程 是UI主线程了。改用其他的线程连接即可。

你可能感兴趣的:([置顶] android.os.NetworkOnMainThreadException exception)