您的位置:首页 > 理论基础 > 计算机网络

android4.0访问不能网络解决方法

2014-02-19 14:14 211 查看
@SuppressLint("NewApi")
protected void onCreate(Bundle savedInstanceState) {
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
.detectDiskReads()
.detectDiskWrites()
.detectNetwork() // or .detectAll() for all detectable problems
.penaltyLog()
.build());
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
.detectLeakedSqlLiteObjects()
.penaltyLog()
.penaltyDeath()
.build());

代码中加入这么一段注释, 可以在主线程访问网络, 难道以后没一个activity里面都加入? 不是很麻烦,每次都需要执行这段代码不是效率不好?
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: