StupidBeauty
Read times:577Posted at:Sat Feb 16 02:55:53 2013
- no title specified

转载解決NetworkOnMainThreadException的問題

从安卓3开始, 不允许在主线程里进行网络操作了。如果妳在主线程里进行网络操作,则会引发 NetworkOnMainThreadException异常。针对 这一点,可将网络相关 的操作放到AsyncTask中去做。

http://droidparadise.blogspot.com/2012/11/networkonmainthreadexception.html

亮点

查了一下原來從Android 3.0開始,Thread Policy加強了限制,只要嘗試在主執行緒中進行網路操作,就會產生這個錯誤。

解決方式有幾個:
1.把網路操作從主執行緒中移走,你可以自己再開一個Thread,或使用
AsyncTask 來執行。

霸气 的雌性官员

Your opinions
Your name:Email:Website url:Opinion content:
- no title specified

HxLauncher: Launch Android applications by voice commands

 
Recent comments
2017年4月~2019年4月垃圾短信排行榜Posted at:Thu Sep 26 04:51:48 2024
Qt5.7文档翻译:QWebEngineCookieStore类,QWebEngineCookieStore ClassPosted at:Fri Aug 11 06:50:35 2023盲盒kill -9 18289 Grebe.20230517.211749.552.mp4