bootstrap easyui RunJS JSFiddle codepen Gist

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

posted @ 2014-02-19 14:14  lvyafei  阅读(242)  评论(0编辑  收藏  举报
博客地址:lvyafei 返回顶部   返回顶部   返回顶部 站长QQ,点击这里给我发消息
无觅关联推荐,快速提升流量