android-async-http开源库实现https
2015-04-19 16:18
316 查看
1.android自带包
新开线程
发送:
接收直接答应出结果:
String str = EntityUtils.toString(responString.getEntity());
System.out.println(str);
2.使用android-async-http包实现异
新开线程
发送:
HttpClient client = new DefaultHttpClient(); HttpPost post = new HttpPost("http://my.csdn.net/"); JSONObject jsonObject = new JSONObject(); try { jsonObject.put("name", "ze"); StringEntity entity = new StringEntity(jsonObject.toString()); post.setEntity(entity); HttpResponse responString = client.execute(post); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ClientProtocolException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); }
接收直接答应出结果:
String str = EntityUtils.toString(responString.getEntity());
System.out.println(str);
2.使用android-async-http包实现异
public static HttpClient httpClient; mAsyncHttpClient = new AsyncHttpClient(); jsonObject.put("name", "ze"); StringEntity entity = new StringEntity(jsonObject.toString()); mAsyncHttpClient.post(context, url, stringEntity, "application/json", new HttpResponse());理类: class HttpResponse extends AsyncHttpResponseHandler { public HttpResponse() { } @Override public void onSuccess(String response) { //结果处理 } } @Override public void onFailure(int statusCode, Header[] headers, byte[] errorResponse, Throwable e) { //错误结果处理 } }
相关文章推荐
- 开源库android-async-http添加https请求方式
- Android开源库loopj的android-async-http的 JsonHttpResponseHandler 存在死循环GC_CONCURRENT
- Android开源库loopj的android-async-http的 JsonHttpResponseHandler 存在死循环GC_CONCURRENT
- 使用android-async-http-master框架实现手机登陆服务器端密码验证
- 09_android入门_采用android-async-http开源项目的GET方式或POST方式实现登陆案例
- 利用android-async-http开源项目实现网络代码查看器
- android---利用android-async-http开源项目实现网络图片查看器
- android-async-http-library 与 volley 内部实现类图对比
- 【Java&Android开源库代码剖析】のandroid-async-http の开篇
- 【Java&Android开源库代码剖析】のandroid-async-http の网络响应ResponseHandlerInter
- android-async-http开源项目GET方式 POST方式实现登陆
- android-async-http开源项目的GET方式或POST方式实现登陆案例简单Demo
- Android中基于HTTP的通信技术(5)Google开源库 使用 Volley 实现 JSON 字符串请求
- 网络数据请求实践一:android-async-http实现下载和上传
- 09_android入门_采用android-async-http开源项目的GET方式或POST方式实现登陆案例
- 网络数据请求实践一:android-async-http实现下载和上传
- 【Java&Android开源库代码分析】のandroid-async-http の开盘
- android入门_采用android-async-http开源项目的GET方式或POST方式实现登陆案例
- 关于androidAsyncHttp支持https
- 09_android入门_採用android-async-http开源项目的GET方式或POST方式实现登陆案例