android-cn / android-discuss

Android 问题交流讨论坛, 微信公众号:codekk, 网站:
https://github.com/android-cn/android-discuss/issues
Apache License 2.0
4.08k stars 536 forks source link

【问答】你应用中的网络层是怎么设计的? #78

Open passionli opened 9 years ago

tanranran commented 9 years ago

我用的是 android-async-http. 封装了下常用的方法,get post 上传 下载 ,所有的请求我都是用的同步请求. 具体的用法一般都是和业务逻辑在一起,而我的业务逻辑是用异步去处理的. 关于网络请求结果的缓存,我是单独处理的.并没有放在网络层.

frankswu commented 9 years ago

ok-http,or 封装的HttpUrlConnection

yanbober commented 9 years ago

afinal或者自己封装

hehonghui commented 9 years ago

看看这个对你有没有用,http://blog.csdn.net/column/details/simple-net.html

sfshine commented 9 years ago

只是用httpurlconnection实现了封装, 后来一些项目中直接使用了xutils

dasunsy commented 9 years ago

在HttpUrlConnection基础上封装, 包括请求成功, 失败, 请求中, 网络问题等封装, 利用广播与UI交互

ayyb1988 commented 9 years ago

volley

ghost commented 9 years ago

retrofit

xfstart07 commented 9 years ago

retrofit

jovezhougang commented 9 years ago

用现成的一些框架 然后根据项目需要自己再封装下,比如说你的交互数据是JSON格式的,你就可以用一个网络请求框架+fastjson ,然后写一些Bean 在Work线程把数据用fastjson 直接解析成对象返回,最后对一些错误统一处理

tadakatsu commented 8 years ago

我一般都是把volley+fastjson做一下封装,或者xutils+fastjson

YiChaoLove commented 8 years ago

volley用的还是比较多的

tianlang commented 8 years ago

用的okhttp,封装了一个线程池和线程队列,设置get post的方法,拼接url地址,以及自动加入用户态信息的方法,封装几种错误状态判断,使用gson解析结果成model在回调中返回。 一般应该都是这种思路吧

thinkfeed commented 8 years ago

okhttp或者retrofit 后台接口写的好的用retrofit比较好用

eleree commented 8 years ago

okhttp~