public interface CurrentWeatherApi {
@GET("/data/2.5/weather?q=California&APPID=e8b8a84d0dcbec867ba66a34d376562f")
Call<CurrentWeather> getCurrentWeather();
}
这是我的界面,我想从动态获取 API 的主 Activity 中传递城市名称
最佳答案
进行以下更改并从传递这些参数的 Activity 中调用
public interface CurrentWeatherApi {
@GET("/data/2.5/weather")
Call<CurrentWeather> getCurrentWeather(@Query("q") String cityName,@Query("APPID") String appID);
}
因此调用如下所示
Call<CurrentWeather> repos = service.getCurrentWeather("California","e8b8a84d0dcbec867ba66a34d376562f");
关于java - 如何将参数从主 Activity 传递到@Get API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48154888/