美文网首页
Retrofit2.0

Retrofit2.0

作者: 菜鸟考官 | 来源:发表于2018-04-16 10:22 被阅读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();
    }

    相关文章

      网友评论

          本文标题:Retrofit2.0

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