【发布时间】:2021-02-14 23:25:21
【问题描述】:
我在res/strings.xml 中有一个字符串
<string name="clientId">dfgljkwm51</string>
我想在我的改造接口类中使用字符串:
public class RetrofitInterfaces {
public interface GetAlbum{
@Headers("Authorization: Client-ID " + clientId) //Want to use the String valye here.
@GET
Call<Feed> listRepos(@Url String url);
}
}
这就是我使用改造电话的方式:
private void makeNetworkCall(String url) {
RetrofitInterfaces.GetAlbum service = RetrofitClientInstance.getRetrofitInstance()
.create(RetrofitInterfaces.GetAlbum.class);
Call<Feed> call = service.listRepos(url);
call.enqueue(new Callback<Feed>() {
. . .
}
如何将此值传递给我的 Retrofit 接口类,以便我可以在标头中使用该值?
【问题讨论】:
标签: android retrofit retrofit2