How to add http interceptor in retrofit in a service generator class

前端 未结 2 637
無奈伤痛
無奈伤痛 2021-01-24 15:12

I created a separate service generator class as shown is this guide https://futurestud.io/tutorials/retrofit-2-manage-request-headers-in-okhttp-interceptor

ApiServiceGen

2条回答
  •  一整个雨季
    2021-01-24 15:53

    You need to use the http client created when building the retrofit instance.

    Retrofit.Builder()
                    .baseUrl(BASE_URL)
                    .client(httpClient)  // This is the line
                    .addConverterFactory(GsonConverterFactory.create());
    

提交回复
热议问题