深入学习Android有关网络连接的内容
2014-07-01 16:06
423 查看
基于实际项目中碰到的些许问题,开始重新深入学习Android网络连接有关知识。
Android的4.1.2版本的AndroidHttpClient模块setSoTimeout之后实际超时时间和设置的时间不一致现象 不知何种原因,高版本平台使用AndroidHttpClient(setSoTimeout设置的超时时间为60秒),实际反应出的超时时间不一致,需要4分钟才超时。 设备1:U880(2.2平台)实际超时时间 = setSoTimeout的时间 设备2:J2(4.1.2平台)实际超时时间 = setSoTimeout的时间 * 4倍
参考资料:
Connecting to the Network | Android Developers
http://developer.android.com/intl/zh-cn/training/basics/network-ops/connecting.html
官方讨论博客:选择最佳HTTP Client
http://android-developers.blogspot.com/2011/09/androids-http-clients.html(需自带梯子)
Android访问网络,使用HttpURLConnection还是HttpClient? - 郭霖的专栏 - 博客频道 - CSDN.NET(翻译好的)
Which client is best? Apache HTTP client has fewer bugs on Eclair(2.0) and Froyo(2.2). It is the best choice for these releases. For Gingerbread(2.3) and better, HttpURLConnection is the best choice. Its simple API and small size makes it great fit for Android. Transparent compression and response caching reduce network use, improve speed and save battery. New applications should use HttpURLConnection; it is where we will be spending our energy going forward.
官方API文档 | Android Developers
http://developer.android.com/intl/zh-cn/reference/java/net/HttpURLConnection.html
开源的针对 HttpURLConnection 的封装,里面还有介绍许多别的开源组件
hgoebl/DavidWebb · GitHub
https://github.com/hgoebl/DavidWebb#not-for-you
较简单的介绍
How to use java.net.URLConnection to fire and handle HTTP requests? - Stack Overflow
较简单的封装
basic-http-client - Basic HTTP client w/ Android AsyncTask wrapper - Google Project Hosting
知识小结:
Android的HTTP Client 有:
1.Apache 的DefaultHttpClient 或 Android基于此再封装一次的 AndroidHttpClient
2.JAVA 的 HttpURLConnection,不过兼容低版本时需注意的有:
private void disableConnectionReuseIfNecessary() { // HTTP connection reuse which was buggy pre-froyo if (Integer.parseInt(Build.VERSION.SDK) < Build.VERSION_CODES.FROYO) { System.setProperty("http.keepAlive", "false"); } }
相关文章推荐
- Android网络连接处理学习笔记
- Android 中的WiFi学习笔记(转载)----WIFI启动 代码流程走读---网络连接流程
- 深入学习:如何实现不同Android设备之间相同应用程序的网络服务发现功能
- android学习之网络连接2
- 学习笔记一 Android 网络是否连接
- Android网络连接处理学习笔记
- android 有关网络连接Permission的区别
- Android网络连接处理学习笔记
- Android学习之——(2)项目中的网络连接相关以及Bitmap处理学习
- cocos2dx网络连接部分深入学习
- Android 中的WiFi学习笔记(转载)----WIFI启动 代码流程走读---网络连接流程
- Android json解析有关内容学习笔记
- Android网络连接处理学习笔记
- Android网络连接处理学习笔记
- Android 网络连接处理 学习笔记
- Android 中的WiFi学习笔记(转载)----WIFI启动 代码流程走读---网络连接流程
- Android网络连接处理学习笔记
- Android 中的WiFi学习笔记(转载)----WIFI启动 代码流程走读---网络连接流程
- android有关网络连接的方法
- 2.28学习内容,android,dialog自定义宽高、ios判断网络可用性