Dagger2, providing Retrofit instances with different APIs same time
You just use the @Inject
annotation along with the @Named()
annotation, like so:
@Inject @Named("provideRetrofit") Retrofit mRetrofit;
@Inject @Named("provideRetrofit2") Retrofit mRetrofit2;
Or you could even inject the Retrofit services directly:
@Provides @Singleton
public CustomService provideCustomService(@Named("provideRetrofit") Retrofit retrofit) {
return retrofit.create(CustomService.class);
}