DEV Community

Discussion on: Who's looking for open source contributors? (October 15th edition)

Collapse
 
kwabenberko profile image
Kwabena Bio Berko

KwabenBerko / OpenWeatherMap-Android-Library

A wrapper for the openweathermap REST API

OpenWeatherMap-Android-Library

You need an API Key to use the OpenWeatherMap API. Head on over to their website if you don't already have one.

Download

Step 1. Add the JitPack repository to your root build.gradle file.

allprojects {
  repositories {
    ...
    maven { url 'https://jitpack.io' }
  }
}

Step 2 : Download via Gradle:

compile 'com.github.KwabenBerko:OpenWeatherMap-Android-Library:v1.1.2'

Note: Remember to include the INTERNET permission to your manifest file

Usage

Instantiate the OpenWeatherMapHelper class

OpenWeatherMapHelper helper = new OpenWeatherMapHelper();

Set your API Key (Required)

helper.setApiKey(getString(R.string.OPEN_WEATHER_MAP_API_KEY));

Set your Units (Optional, Standard by default)

helper.setUnits(Units.IMPERIAL);
Unit Options:
  1. Units.IMPERIAL (Fahrenheit)

  2. Units.METRIC (Celsius)

Set language (default : en)

helper.setLang(Lang.ENGLISH);

Features

(1) Current Weather

Get current weather by City Name:

helper.getCurrentWeatherByCityName("Accra", new OpenWeatherMapHelper.CurrentWeatherCallback()