情况:
点击登录按钮出错,提示android.os.NetworkOnMainThreadException
原因:
在主线程中访问了网络
API-9以上可以使用
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectDiskReads().detectDiskWrites().detectNetwork().penaltyLog().build());
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectLeakedSqlLiteObjects().penaltyLog().penaltyDeath().build());