本文介绍了与Android崩溃HTTP POST请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下的的Java code:

  {尝试
    HttpClient的HttpClient的=新DefaultHttpClient();
    HttpPost httppost =新HttpPost(http://192.168.1.105/test.php);    清单<&的NameValuePair GT;睾丸=新的ArrayList<&的NameValuePair GT;(1);
    teste.add(新BasicNameValuePair(测试,测试));
    httppost.setEntity(新UrlEn codedFormEntity(测试));    HTT presponse响应=(HTT presponse)httpclient.execute(httppost);
}赶上(IOException异常五){
    e.printStackTrace();
}

每当我去掉/注释行的Htt presponse响应=(HTT presponse)httpclient.execute(httppost); 应用程序崩溃/没有按' ŧ崩溃,分别我对清单互联网许可,我想从服务器获取一个json_en codeD消息。我想一切,但仍不能设法把它的工作。

日志:

解决方案

You should put your code in the AsyncTask for background performance.

But for a better way of downloading Server data use a framework called AsyncHttpClient, you can find it here:

AsyncHttpClient

这篇关于与Android崩溃HTTP POST请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 17:59
查看更多