1.afinal
2.volley
个人觉得不错的两个框架!当然也可以自己封装。如果对以上两个框架感兴趣,可以下源码研究.都是开源的。也可以在他们框架的基础上改进。
对Volley Google I/O开源框架 进行封装http://blog.csdn.net/gao_chun/article/details/34117083
2.volley
个人觉得不错的两个框架!当然也可以自己封装。如果对以上两个框架感兴趣,可以下源码研究.都是开源的。也可以在他们框架的基础上改进。
对Volley Google I/O开源框架 进行封装http://blog.csdn.net/gao_chun/article/details/34117083
/**
* 发送post请求
*/
public String gerReslut(String url, List<NameValuePair> params) {
HttpPost httpRequest = new HttpPost(url);
String str = "error";
try {
BasicHttpParams httpParams = new BasicHttpParams();
HttpConnectionParams.setConnectionTimeout(httpParams,
REQUEST_TIMEOUT);
HttpConnectionParams.setSoTimeout(httpParams, SO_TIMEOUT);
HttpClient httpClient = new DefaultHttpClient(httpParams);
httpRequest.setEntity(new UrlEncodedFormEntity(params, "utf-8"));
HttpResponse httpResponse = httpClient.execute(httpRequest);
if (httpResponse.getStatusLine().getStatusCode() == 200) {
str = EntityUtils.toString(httpResponse.getEntity(), "GBK");
System.out.println("----->" + str);
return str;
} else {
return null;
} } catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return null; }