这个异常大概意思是在主线程访问网络时出的异常。 Android在4.0之前的版本 支持在主线程中访问网络,但是在4.0以后对这部分程序进行了优化,也就是说访问网络的代码不能写在主线程中了。
用多线程可解决:
1 new Thread(){ 2 @Override 3 public void run() { 4 // TODO Auto-generated method stub 5 super.run(); 6 //访问网络 7 } 8 }.start();