Android改造@GET参数

时间:2015-10-17 15:41:55

标签: android json get gson retrofit

我有这个界面来获取城市RZESZOW和国家波兰的天气(来自openweather API),我如何查询参数?我需要从用户那里获取城市名称和国家/地区

public interface RestInterface {

@GET("/weather?q=rzeszow,pl&appid=527f7a1296bd7b0f21e47fc01a982087")
void getWheatherReport(Callback<Model> cb);

}

我称之为

  //making object of RestAdapter
    RestAdapter adapter = new RestAdapter.Builder().setEndpoint(url).build();

    //Creating Rest Services
    RestInterface restInterface = adapter.create(RestInterface.class);

    //Calling method to get whether report
    restInterface.getWheatherReport(new Callback<Model>() {
        @Override
        public void success(Model model, Response response) {
STUFF HERE >>>>>>>>>>>>>>.........<<<<<<<<<<<<<
}

我在哪里可以了解有关Retrofit,APIS,JSON等的更多信息?

1 个答案:

答案 0 :(得分:1)

如果您想传递参数,可以使用@Query

在你的情况下

@GET("/weather")
void getWheatherReport(@Query("q") String place, @Query("appid") String appId, Callback<Model> cb);

您可以在此处阅读更多内容 - enter link description here

相关问题