android.os.NetworkOnMainThreadException
来源:互联网 发布:英国公学。知乎 编辑:程序博客网 时间:2024/06/02 12:03
错误:Caused by: android.os.NetworkOnMainThreadException
AndroidManifest.xml中已经加入了网络访问权限:
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission>"
原因:API中StrictMode类详细说明。
解决办法:
按照API给的方法
方法onCreate()中加入如下代码:
public void onCreate() { if (DEVELOPER_MODE) { StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder() .detectDiskReads() .detectDiskWrites() .detectNetwork() // or .detectAll() for all detectable problems .penaltyLog().build()); StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder() .detectLeakedSqlLiteObjects() .detectLeakedClosableObjects() .penaltyLog() .penaltyDeath() .build()); } super.onCreate(); }
- 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
- 次数加时间限制及限制代理访问或在服务器上面禁掉可疑IP访问
- Android初级篇-Adaper,LayoutInflater,Viewholder的使用
- [原创]将RHEL5/CentOS5的GNOME改成KDE
- bmp图像格式 读二进制方式
- c++ 数据类型转换(RTTI)
- android.os.NetworkOnMainThreadException
- nfs
- 停下来与自己的心对话
- union 和order by 连接使用报错的问题
- 五险一金,你知道多少
- Yum被锁定以及其解决方法
- sql去重查询的另一种方式
- 对于开发环境无法升级checkin等各种乱七八糟的问题的最终解释
- SQL2008 附加数据库提示 5120错误