Android 使用带有WeatherAPI的翻新@GET-静态参数

Android 使用带有WeatherAPI的翻新@GET-静态参数,android,api,retrofit,Android,Api,Retrofit,我正在使用OpenWeatherAPI,并在改装时首次尝试。我正试图将预测拉到X天数的范围内。forecast API的文档可在以下位置找到: 与特定城市的预测相关的API链接如下: api.openweathermap.org/data/2.5/forecast/daily?q={city name},{country code}&cnt={cnt} 我的基本URL为: api.openweathermap.org/data/2.5/forecast/daily? 对于如何满足@

我正在使用OpenWeatherAPI,并在改装时首次尝试。我正试图将预测拉到X天数的范围内。forecast API的文档可在以下位置找到:

与特定城市的预测相关的API链接如下:

api.openweathermap.org/data/2.5/forecast/daily?q={city name},{country code}&cnt={cnt}
我的基本URL为:

api.openweathermap.org/data/2.5/forecast/daily?
对于如何满足@GET注释和异步响应的相关方法,我有点困惑。API链接中的“&”也令人困惑,因为我不知道是否会在@GET注释中包含API调用的静态部分。以下是我所拥有的:

public interface WeatherAPI {

@GET("/forecast/daily?")
void getResponse(@Query("city")String city, @Query("country_code") int countryCode, @Query("number_of_days") int number_of_days, Callback<List<WeatherForecast>> response);

 }
公共接口WeatherAPI{
@获取(“/forecast/daily?”)
void getResponse(@Query(“city”)字符串city,@Query(“country\u code”)int countryCode,@Query(“天数”)int number\u of\u days,回调响应);
}

如果您能帮助解决这一具体问题,以及如何解决改装问题,我们将不胜感激

它应该可以正常工作。改装会处理
符号

public interface WeatherAPI {
    @GET("/forecast/daily?")
    void getResponse(
                    @Query("city") String city,
                    @Query("country_code") int countryCode,
                    @Query("number_of_days") int number_of_days,
                    Callback<List<WeatherForecast>> response
    );    
}
这是我的改装接口方法:

@GET("/posts/")
void getPostPage(
                 @Query("page") int page,
                 @Query("page_size") int pageSize,
                 Callback<PostPage> callback
);
@GET(“/posts/”)
过期作废(
@查询(“页面”)整型页面,
@查询(“页面大小”)int pageSize,
回调
);

它应该可以正常工作。改装会处理
符号

public interface WeatherAPI {
    @GET("/forecast/daily?")
    void getResponse(
                    @Query("city") String city,
                    @Query("country_code") int countryCode,
                    @Query("number_of_days") int number_of_days,
                    Callback<List<WeatherForecast>> response
    );    
}
这是我的改装接口方法:

@GET("/posts/")
void getPostPage(
                 @Query("page") int page,
                 @Query("page_size") int pageSize,
                 Callback<PostPage> callback
);
@GET(“/posts/”)
过期作废(
@查询(“页面”)整型页面,
@查询(“页面大小”)int pageSize,
回调
);

谢谢!我会给它一个测试,让你知道它是否工作!我是编程新手,所以改型有点高级,但它似乎封装了我以前读过的许多原始AsyncTask类。谢谢!我会给它一个测试,让你知道它是否工作!我是编程新手,所以改型有点高级,但它似乎封装了我以前读过的许多原始AsyncTask类。