Skip to content

kevinzetterstrom/forecast-android

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

forecast-android

An Android library to integrate the Forecast API into your application

Contents

Getting Started

For a more in depth look at the usage, refer to the example Android app.

Gradle

Specify the dependency in your build.gradle file (make sure jcenter() is included as a repository)

compile 'android.zetterstrom.com.forecast:forecast:1.2.1'

Forecast API Registration

In order to use the Forecast API, you will need to register as developer with them, and obtain an API key

Reference

Configure the library

Before you can make a request with the Forecast library, you must configure it.

ForecastConfiguration configuration =
    new ForecastConfiguration.Builder(API_KEY)
        .setCacheDirectory(getCacheDir())
        .build();
ForecastClient.create(configuration);

Make a forecast request

double latitude = 40.2712;
double longitude = -74.7829;
ForecastClient.getInstance()
                    .getForecast(latitude, longitude, new Callback<Forecast>() {
                        @Override
                        public void onResponse(Call<Forecast> forecastCall, Response<Forecast> response) {
                            if (response.isSuccess()) {
                                Forecast forecast = response.body();
                            }
                        }

                        @Override
                        public void onFailure(Call<Forecast> forecastCall, Throwable t) {

                        }
                    });