如何在Android应用中正确使用weatherbit.io api

时间:2019-07-20 04:48:04

标签: android retrofit2

我正在使用get的请求来获取来自weatherbit.io的api的天气数据。如何正确使用base Urlrelative url

我尝试在我的主要活动中使用base url,在我创建的界面中使用relative url。但是在textview中没有得到任何输出

我的主要活动:

 Retrofit retrofit=new Retrofit.Builder().baseUrl("https://api.weatherbit.io/v2.0/").addConverterFactory(GsonConverterFactory.create()).build();
 OpenWeatherMapApi openWeatherMapApi=retrofit.create(OpenWeatherMapApi.class);

   Call<List<Post>> call=openWeatherMapApi.getPosts("my_city_name","my_country_name","my_key");

我的改装界面:

@GET("forecast/daily")
Call<List<Post>> getPosts(@Query("city")String city,@Query("country")String country,@Query("key")String key);

0 个答案:

没有答案