This might be a wrong approach, but I am trying to find a way to re-instantiate an underlying Retrofit \ OkHttpClient
which is annotated with @Singleton
.
The use case is that on the very first app start it will have a different URL. Then after the login and consecutive launches it will use the URL from the SharedPreferences
. It looks like this
@Module
public class NetModule {
@Provides
@Singleton
WrapperClass providesAPI() {
// underlying call with new Retrofit.Builder().client(okHttpClient).baseUrl(url)
return new WrapperClass("someURLToProvision");
}
}
And in the Activity
I inject it with
@Inject protected WrapperClass api;
After the provisioning I will no longer have the URL someURLToProvision
but the actual URL which is stored in the SharedPreferences
.
The question is: Can I re-instantiate the Singleton
so it will not take the hard coded URL, but the one from the SharedPreference
?