Retrofit2.0

2018-04-16  本文已影响0人  菜鸟考官
 // 在创建Retrofit实例时通过.baseUrl()设置
    Retrofit retrofit = new Retrofit.Builder()
            .baseUrl("http://v.juhe.cn/toutiao/") //设置网络请求的Url地址
            .addConverterFactory(GsonConverterFactory.create()) //设置数据解析器
            .build();


    //创建—— 网络请求接口—— 实例
     APIService request = retrofit.create(APIService.class);

    //调用网络请求接口实例,得到对应的Call
    Call<JuheBean> call = request.getData();
    //开启异步
    call.enqueue(callback);

public interface APIService {
@GET("index?&type=&key=606d652cb2c7c8920cc5904a1ed8e671")
Call<JuheBean> getData();
}
上一篇下一篇

猜你喜欢

热点阅读