[转载]httpClient.execute抛Connection to refused异常问题

在4.0之后android采用了严格模式:所以在你得activity创建的时候,在super.onCreate(savedInstanceState);后面加上这个
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
.detectDiskReads()
.detectDiskWrites()
.detectAll() // or .detectAll() for all detectable problems
.penaltyLog()
.build());
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
.detectLeakedSqlLiteObjects()
.detectLeakedClosableObjects()
.penaltyLog()
.penaltyDeath()
.build());
posted @ 2016-05-24 11:21  Jingle Guo  阅读(922)  评论(0编辑  收藏  举报