首页 > 移动平台 > 详细

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

时间:2014-02-19 21:50:11      阅读:375      评论:0      收藏:0      [点我收藏+]

@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里面都加入? 不是很麻烦,每次都需要执行这段代码不是效率不好?

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

原文:http://www.cnblogs.com/lvfeilong/p/sdafd3243243.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!