Android HttpClient : NetworkOnMainThreadException

后端 未结 4 1024
离开以前
离开以前 2020-11-29 12:45

I have some code below:

protected void testConnection(String url) {
    DefaultHttpClient httpclient = new DefaultHttpClient();
    HttpGet httpget = new Htt         


        
4条回答
  •  星月不相逢
    2020-11-29 13:31

    You cant perform network operations in event thread, since android Api Level 11. Instead you should do network operation in another thread than event thread, and use Handler or Asynctask to do so.

提交回复
热议问题