android 使用TheadSafeClientConnManager
来源:互联网 发布:php 五子棋源代码 编辑:程序博客网 时间:2024/05/19 20:41
1.创建HttpClient的关键代码:
HttpParams params = new BasicHttpParams(); //版本 HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1); //编码 HttpProtocolParams.setContentCharset(params, HTTP.DEFAULT_CONTENT_CHARSET); //Activates 'Expect: 100-continue' handshake for the entity enclosing methods. HttpProtocolParams.setUseExpectContinue(params, true); //最大连接数 ConnManagerParams.setMaxTotalConnections(params,100); //超时 HttpConnectionParams.setConnectionTimeout(params,3000); HttpConnectionParams.setSoTimeout(params,3000); //计划注册,可以注册多个计划 SchemeRegistry schReg = new SchemeRegistry(); schReg.register(new Scheme("http", PlainSocketFactory .getSocketFactory(), 80)); ClientConnectionManager conMgr = new ThreadSafeClientConnManager( params, schReg);
return new DefaultHttpClient(conMgr, params);
2.需要注意的事项,及时释放all allocated resources
4.1以前需要使用 httpEntity.consumeContent();方法释放资源保持Connection alive
4.1以后HttpClient通过判断inputStream.close();方法是否调用来释放资源
- android 使用TheadSafeClientConnManager
- Android使用
- Android使用
- Android使用
- 【android】 android studio使用
- android使用keytools使用
- 【Android】Android LogCat使用详解
- 【Android】Android LogCat使用详解
- Android:Android Fragments 详细使用
- android布局 android:Theme使用
- #android#android studio 使用cardview
- 【android】:android之使用Intent
- 【Android】Android对话框的使用
- 【Android】android Fragment的使用
- 【Android】Android SurfaceView使用详解
- Android进阶---android databinding 使用
- android:Android中pullToRefresh使用
- Android WebView使用【初级使用】
- eclipse 修改插件
- 关于爱情
- 查询语句之聚合函数
- 练习 asp.net 网银支付
- Android 用线程来实现远程下载
- android 使用TheadSafeClientConnManager
- makefile 相同目标的合并
- MFC练习小结:单文本文档
- MySql触发器之入库与出库
- android 网络图片缓存策略
- Objective-C单例实现
- OpenGL 与显卡
- UvaOJ445
- 21个免费的UI界面设计工具、资源及网站