[安卓开发]Socket通信莫名奇妙的退出
时间:2014-01-21 09:40:51
收藏:0
阅读:398
进行socket通信时,除了要添加权限,还需要在onCreate中添加如下的函数来取消strictmode
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());
不然,会莫名其妙的退出,而且没有任何异常信息。
原文:http://blog.csdn.net/pengqianhe/article/details/18257185
评论(0)