android.os.NetworkOnMainThreadException
来源:互联网 发布:吃鸡网络延迟检测 编辑:程序博客网 时间:2024/06/09 22:40
错误原因:
4.0的系统,在主线程中调用了http相关的方法。
StrictMode is a developer tool which detects things you might be doing by accident and brings them to your attention so you can fix them.
StrictMode is most commonly used to catch accidental disk or network access on the application's main thread, where UI operations are received and animations take place. Keeping disk and network operations off the main thread makes for much smoother, more responsive applications. By keeping your application's main thread responsive, you also prevent ANR dialogs from being shown to users.
参考:
http://developer.android.com/reference/android/os/StrictMode.html
解决办法:
如果是在Activity中,可以使用AsyncTask
http://blog.csdn.net/icephone/article/details/6633024
Service中使用Thread和Handler。
PS:待完善。
- android.os.NetworkOnMainThreadException问题
- android.os.NetworkOnMainThreadException问题
- android.os.NetworkOnMainThreadException
- android.os.NetworkOnMainThreadException
- android.os.NetworkOnMainThreadException
- android.os.NetworkOnMainThreadException异常
- 关于android.os.NetworkOnMainThreadException
- android.os.NetworkOnMainThreadException
- android.os.NetworkOnMainThreadException
- android.os.NetworkOnMainThreadException
- 异常:android.os.NetworkOnMainThreadException
- android.os.NetworkOnMainThreadException
- android.os.NetworkOnMainThreadException异常
- android.os.NetworkOnMainThreadException
- exception: android.os.NetworkOnMainThreadException
- 异常:android.os.NetworkOnMainThreadException
- android.os.NetworkOnMainThreadException
- 异常android.os.NetworkOnMainThreadException
- 即时通讯开发平台的部分C#代码
- Android Intent和PendingIntent的区别详细分析
- Android JNI入门第六篇——C调用Java
- ORA-04098:触发器无效且未通过重新验证
- Java中,ArrayList的contains()和HashSet的contains()的区别,哈希值问题
- android.os.NetworkOnMainThreadException
- [java]HttpSessionListener实现统计在线人数
- Ubuntu软件源
- 【Cocos2d-x游戏引擎开发笔记(9)】实现DotA的技能冷却效果
- Java 中String转化为byte数组
- MFC读取操作文件
- 中国经济稳中求进又是一年
- js中类似explode的方法
- 有待试用,查看是谁锁住了我的数据库