Retrofit与okhttp共同出自于Square公司,retrofit就是对okhttp做了一层封装。把网络请求都交给给了Okhttp,我们只需要通过简单的配置就能使用retrofit来进行网络请求了,其主要作者是Android大神JakeWharton。

导包:
compile 'com.squareup.retrofit2:retrofit:2.0.0-beta4'//Retrofit2所需要的包
compile 'com.squareup.retrofit2:converter-gson:2.0.0-beta4'//ConverterFactory的Gson依赖包
compile 'com.squareup.retrofit2:converter-scalars:2.0.0-beta4'//ConverterFactory的String依赖包
*这里需要值得注意的是导入的retrofit2包的版本必须要一致,否则就会报错。
首先定义我们请求的Api,我们假设是这样的
http://106.3.227.33/pulamsi/mobileLogin/submit.html
与Okhttp不同的是,Retrofit需要定义一个接口,用来返回我们的Call对象,这里示范的是Post请求:
public interface RequestServes {
@POST("mobileLogin/submit.html")
Call getString(@Query("loginname") String loginname,
@Query("nloginpwd") String nloginpwd);
} 
售后响应及时
7×24小时客服热线
数据备份
更安全、更高效、更稳定
价格公道精准
项目经理精准报价不弄虚作假
合作无风险
重合同讲信誉,无效全额退款