美文网首页
2018-03-26 Retrofit简单使用

2018-03-26 Retrofit简单使用

作者: KryNa | 来源:发表于2018-03-26 16:05 被阅读0次

1.添加依赖

compile'com.squareup.retrofit2:retrofit:2.0.2'

compile'com.squareup.okhttp3:okhttp:3.1.2'

需要解析数据则需要添加依赖:(可选)

compile'com.squareup.retrofit2:converter-gson:2.0.2'

compile'com.squareup.retrofit2:adapter-rxjava:2.0.2'

2.创建bean类对象

bean对象

3.创建用于描述网络请求的接口

post: 使用POST注解,使用@FormUrlEncoded与@Field来发送参数

get: 使用GET注解

post get

4.

步骤1:创建 Retrofit 实例

步骤2:创建 网络请求接口实例 并 配置网络请求参数

步骤3:发送网络请求(异步 / 同步)

步骤4:处理服务器返回的数据

get post

参照:https://blog.csdn.net/carson_ho/article/details/73732076

相关文章

网友评论

      本文标题:2018-03-26 Retrofit简单使用

      本文链接:https://www.haomeiwen.com/subject/efurcftx.html