I want to work with multiple base url in retrofit2 #3696
Unanswered
aumobiletools
asked this question in
Q&A
Replies: 2 comments
-
I would implement a @Override
public Call newCall(@Nonnull Request request) {
HttpUrl updatedUrl = request
.url()
.newBuilder()
.host("my.new.host")
.build();
Request updatedRequest = request.newBuilder().url(updatedUrl).build();
return delegateClient.newCall(updatedRequest);
} |
Beta Was this translation helpful? Give feedback.
0 replies
-
I resolved it by create a new interceptor which can change host url.
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a structure whose base url address is constantly variable. When my user changes his location in the application, I change the base url to show the closest server to him. but the retrofit client does not regenerate even though I restart the activities and change all the static variables. The only way to do this is to close the application completely and restart it.
I don't have a fixed base url. There could be 4 different locations today, 12 different locations tomorrow. so i need to find a permanent solution.
I have examined a lot in debug mode, but; When the base url changes, it never goes inside the getClient and cannot reassign the base url.
Beta Was this translation helpful? Give feedback.
All reactions