Our team decides to adopt Retrofit 2.0, and I am doing some initial research on this. I am new to this library.
I am wondering how to use interceptor to add custom headers via Retrofits 2.0 to our Android app. There are many guides to using interceptor to add headers in Retrofit 1.X, but since the APIs have changed a lot in the latest version, I'm not sure how to adapt these methods in the new version. In addition, Retrofit has not yet updated its new documentation.
For example, in the following codes, how do I implement the Interceptor class to add additional headers? Also, what exactly is an undocumented Chain object ? When will intercept() be called?
OkHttpClient client = new OkHttpClient(); client.interceptors().add(new Interceptor() { @Override public Response intercept(Chain chain) throws IOException { Response response = chain.proceed(chain.request());
java android retrofit
hackjutsu Oct 06 '15 at 6:43 2015-10-06 06:43
source share