Android Weather Library: android weather lib to develop weather based app fast and easily

Related tags

SDK WeatherLib
Overview

WeatherLib

Android weather lib is an android weather aggregator. The lib helps you getting weather data from the most importat weather provider. It supports:

  • Openweathermap
  • Yahoo! Weather
  • Weatherunderground
  • Weather.com
  • Forecast.io

Weatherlib has a new (web site)

#Travis integration Master Build Status

#Version 1.6.0

dependencies {					
	compile 'com.survivingwithandroid:weatherlib:1.6.0'
	compile 'com.survivingwithandroid:weatherlib_volleyclient:1.6.0'
	compile 'com.mcxiaoke.volley:library:1.0.6@aar' (or whatever you like)
}
dependencies {					
	compile 'com.survivingwithandroid:weatherlib:1.6.0'
	compile 'com.survivingwithandroid:weatherlib_okhttpclient:1.6.0'
	compile 'com.squareup.okhttp:okhttp:2.0.+'
}

#Community If you like there is a Community to talk about new features, suggest tips or report bugs. Please join:

#Credits Author: Francesco Azzola ([email protected])

#License

Copyright 2012-2014 Francesco Azzola (Surviving with Android)

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Comments
  • getCurrentCondition JSONException: No value for deg

    getCurrentCondition JSONException: No value for deg

    I get the following error while using getCurrentCondition with OpenWeatherMap :

    org.json.JSONException: No value for deg
     at org.json.JSONObject.get(JSONObject.java:389)
     at org.json.JSONObject.getDouble(JSONObject.java:444)
     at com.survivingwithandroid.weather.lib.provider.openweathermap.OpenweathermapProvider.getFloat(OpenweathermapProvider.java:514)
     at com.survivingwithandroid.weather.lib.provider.openweathermap.OpenweathermapProvider.getCurrentCondition(OpenweathermapProvider.java:135)
     at com.survivingwithandroid.weather.lib.client.okhttp.WeatherDefaultClient$4.onResponse(WeatherDefaultClient.java:380)
     at com.squareup.okhttp.Call$AsyncCall.execute(Call.java:162)
     at com.squareup.okhttp.internal.NamedRunnable.run(NamedRunnable.java:33)
     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
     at java.lang.Thread.run(Thread.java:818)
    
    opened by ClementHard 9
  • No value for ground level, my app is crashing !

    No value for ground level, my app is crashing !

    Hi,

    My app is crashing in production : org.json.JSONException: No value for grnd_level org.json.JSONObject.get(JSONObject.java:389) org.json.JSONObject.getDouble(JSONObject.java:444) com.survivingwithandroid.weather.lib.provider.openweathermap.OpenweathermapProvider.getFloat(OpenweathermapProvider.java:514) com.survivingwithandroid.weather.lib.provider.openweathermap.OpenweathermapProvider.getCurrentCondition(OpenweathermapProvider.java:126) com.survivingwithandroid.weather.lib.client.okhttp.WeatherDefaultClient$4.onResponse(WeatherDefaultClient.java:380) com.squareup.okhttp.Call$AsyncCall.execute(Call.java:170) com.squareup.okhttp.internal.NamedRunnable.run(NamedRunnable.java:33) java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) java.lang.Thread.run(Thread.java:818)

    I don't know why but OpenWeatherLib does not always provide ground_pressure and sea_pressure. For instance : http://api.openweathermap.org/data/2.5/weather?mode=json&lat=48.7563952&lon=2.3055305&units=metric&lang=en http://api.openweathermap.org/data/2.5/weather?mode=json&lat=43.7563952&lon=2.3055305&units=metric&lang=en

    opened by fabreax 6
  • getHourForecastWeather in OkHttpClient

    getHourForecastWeather in OkHttpClient

    getHourForecastWeather in OkHttpClient is not executed in the main thread.

    See here: http://stackoverflow.com/questions/24498340/tabs-with-viewpager-fragments-working-in-wrong-context

    bug 
    opened by survivingwithandroid 5
  • JSONException error

    JSONException error

    Hi,

    I'm using your fantastic lib with Okhttp & OpenStreetMap. I'm trying to get the current condition in Paris (id = 2988507), but it fails with this logcat :

    07-24 15:46:01.515 1974-1986/com.easycell.daydream W/System.err﹕ org.json.JSONException: End of input at character 0 of 07-24 15:46:01.515 1974-1986/com.easycell.daydream W/System.err﹕ at org.json.JSONTokener.syntaxError(JSONTokener.java:450) 07-24 15:46:01.515 1974-1986/com.easycell.daydream W/System.err﹕ at org.json.JSONTokener.nextValue(JSONTokener.java:97) 07-24 15:46:01.515 1974-1986/com.easycell.daydream W/System.err﹕ at org.json.JSONObject.(JSONObject.java:154) 07-24 15:46:01.515 1974-1986/com.easycell.daydream W/System.err﹕ at org.json.JSONObject.(JSONObject.java:171) 07-24 15:46:01.515 1974-1986/com.easycell.daydream W/System.err﹕ at com.survivingwithandroid.weather.lib.provider.openweathermap.OpenweathermapProvider.getCurrentCondition(OpenweathermapProvider.java:85) 07-24 15:46:01.515 1974-1986/com.easycell.daydream W/System.err﹕ at com.survivingwithandroid.weather.lib.client.okhttp.WeatherDefaultClient$4.onResponse(WeatherDefaultClient.java:306) 07-24 15:46:01.515 1974-1986/com.easycell.daydream W/System.err﹕ at com.squareup.okhttp.Call$AsyncCall.execute(Call.java:150) 07-24 15:46:01.515 1974-1986/com.easycell.daydream W/System.err﹕ at com.squareup.okhttp.internal.NamedRunnable.run(NamedRunnable.java:33) 07-24 15:46:01.515 1974-1986/com.easycell.daydream W/System.err﹕ at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076) 07-24 15:46:01.515 1974-1986/com.easycell.daydream W/System.err﹕ at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569) 07-24 15:46:01.515 1974-1974/com.easycell.daydream W/System.err﹕ com.survivingwithandroid.weather.lib.exception.WeatherLibException: org.json.JSONException: End of input at character 0 of 07-24 15:46:01.515 1974-1974/com.easycell.daydream W/System.err﹕ at com.survivingwithandroid.weather.lib.provider.openweathermap.OpenweathermapProvider.getCurrentCondition(OpenweathermapProvider.java:167) 07-24 15:46:01.515 1974-1974/com.easycell.daydream W/System.err﹕ at com.survivingwithandroid.weather.lib.client.okhttp.WeatherDefaultClient$4.onResponse(WeatherDefaultClient.java:306) 07-24 15:46:01.515 1974-1974/com.easycell.daydream W/System.err﹕ at com.squareup.okhttp.Call$AsyncCall.execute(Call.java:150) 07-24 15:46:01.515 1974-1974/com.easycell.daydream W/System.err﹕ at com.squareup.okhttp.internal.NamedRunnable.run(NamedRunnable.java:33) 07-24 15:46:01.515 1974-1974/com.easycell.daydream W/System.err﹕ at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076) 07-24 15:46:01.515 1974-1974/com.easycell.daydream W/System.err﹕ at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569) 07-24 15:46:01.515 1974-1974/com.easycell.daydream W/System.err﹕ at java.lang.Thread.run(Thread.java:856) 07-24 15:46:01.515 1974-1974/com.easycell.daydream W/System.err﹕ Caused by: org.json.JSONException: End of input at character 0 of 07-24 15:46:01.515 1974-1974/com.easycell.daydream W/System.err﹕ at org.json.JSONTokener.syntaxError(JSONTokener.java:450) 07-24 15:46:01.515 1974-1974/com.easycell.daydream W/System.err﹕ at org.json.JSONTokener.nextValue(JSONTokener.java:97) 07-24 15:46:01.515 1974-1974/com.easycell.daydream W/System.err﹕ at org.json.JSONObject.(JSONObject.java:154) 07-24 15:46:01.515 1974-1974/com.easycell.daydream W/System.err﹕ at org.json.JSONObject.(JSONObject.java:171) 07-24 15:46:01.515 1974-1974/com.easycell.daydream W/System.err﹕ at com.survivingwithandroid.weather.lib.provider.openweathermap.OpenweathermapProvider.getCurrentCondition(OpenweathermapProvider.java:85) 07-24 15:46:01.515 1974-1974/com.easycell.daydream W/System.err﹕ ... 6 more 07-24 15:46:01.515 1974-1986/com.easycell.daydream W/System.err﹕ at java.lang.Thread.run(Thread.java:856)

    Any solution?

    opened by g123k 4
  • Manifest error

    Manifest error

    Could u explain this , or if i have somehow missing or incomplete Manifest

    <application android:allowBackup="true"
        android:label="@string/app_name"
        android:icon="@drawable/ic_launcher"
    
    </application>
    
    opened by aldefy 4
  • OpenWeatherMap provider object parsing error

    OpenWeatherMap provider object parsing error

    Hi,

    it is possible that i found a small parsing bug by using the OpenWeatherMap provider?

    File: OpenweathermapProvider.java Method: getCurrentCondition Line: weather.currentCondition.setPressure(getInt("pressure", mainObj));

    This should be: weather.currentCondition.setPressure(getFloat("pressure", mainObj));

    Because the OpenweatherMap provider returns this value as float value:

    Watch the pressure value in the example file below:

    {"message":"like","cod":"200","count":1,"list":[{"id":5689557,"name":"Hazen","coord":{"lon":-101.625,"lat":47.3016},"main":{"temp":271.935,"temp_min":271.935,"temp_max":271.935,"pressure":960.51,"sea_level":1035.23,"grnd_level":960.51,"humidity":69},"dt":1421261739,"wind":{"speed":6.35,"deg":261.516},"sys":{"country":"United States of America"},"clouds":{"all":8},"weather":[{"id":800,"main":"Clear","description":"Sky is Clear","icon":"02d"}]}]}

    opened by CH4MPi 3
  • NullPointerException When Giving Config Settings

    NullPointerException When Giving Config Settings

    I am trying to use WeatherLib in my app. However, when I try to set up the config, I get a NullPointerException. I cannot find a way to fix it, and I have used the code provided. Any pointers?

    ` WeatherClient weatherClient = WeatherClientDefault.getInstance();

        weatherClient.init(this);
        WeatherConfig config = new WeatherConfig();
        config.unitSystem = WeatherConfig.UNIT_SYSTEM.M;
        config.lang = "en";
        config.maxResult = 5;
        config.numDays = 6;
        weatherClient.updateWeatherConfig(config); //This is where I get the error
        IWeatherProvider provider = null;
        try{
            provider = WeatherProviderFactory.createProvider(new YahooProviderType(), config);
            weatherClient.setProvider(provider);
        } catch (Throwable t){}
    
        ListView listView = findViewById(R.id.list);
    
        WeatherAdapter adapter = new WeatherAdapter(getApplicationContext(), R.layout.row_view, cities, weatherClient);
        listView.setAdapter(adapter);`
    

    Any help provided is appreciated.

    opened by vdaita 2
  • Project dead?

    Project dead?

    The last commit was in November 2015 and the issues kept unanswered. So, i assume this project dead? Unfortunately i got some issues with it. Somebody knows an alternative weather lib for Android?

    opened by KlausHans 2
  • getHistoricalWeather throws WeatherLibException

    getHistoricalWeather throws WeatherLibException

    When calling the getHistoricalWeather method it throws this exception using version 1.5.1: com.survivingwithandroid.weather.lib.exception.WeatherLibException: org.json.JSONException: Value [{"id":801,"icon":"02d","description":"few clouds","main":"Clouds"}] at weather of type org.json.JSONArray cannot be converted to JSONObject

    Using OpenweathermapProviderType

    bug 
    opened by StefanPerssonIT 2
  • Fix parsing time in Yahoo provider if default locale is not english

    Fix parsing time in Yahoo provider if default locale is not english

    There seems to be a bug in android which causes this problem. Try to run these 2 lines with the system language set to German:

    SimpleDateFormat sdf = new SimpleDateFormat("h:mm a"); Date d = sdf.parse("7:18 am");

    It will fail with ParseException because it doesn't recognize "am" because it expects "vorm". (Short for "Vormittag")

    Since Yahoo only supports english anyway (and has no intent to change that https://developer.yahoo.com/forum/General-Discussion-at-YDN/Can-Yahoo-Weather-API-show-by/1275022713000-d78748d9-0247-313b-ad9e-3503b8ea3d07/) we can set the locale to English when parsing to avoid this issue.

    As a side note: Samsung seems to have patched this android bug because its working fine on different kinds of Samsung tablets.

    I reproduced this bug on Android 4.2.2, and 5.1.1.

    opened by m-rm 1
  • Timestamp returned from Hourlly Forecast in strange format

    Timestamp returned from Hourlly Forecast in strange format

    Hi there ! I'm using the weatherlib with onpenweathermap provider and when I get the hourly forecast the timestamp is returned on a strange format:

    timestamp: 1441897200 temp: 19.61 timestamp: 1441908000 temp: 16.75 timestamp: 1441918800 temp: 13.8

    The convertion to Date format came with a date on Febuary, 1970.... so I believe that this format is not the regular timestamp long from January, 1st, 1970...

    I can see a sequence in the middle of the number: 189, 190, 191... but I could not find a logic to find a reference to a valid time value.

    Could you help me ?

    Thanks,

    Elcio A.

    opened by elcioabrahao 1
  • WeatherCode unavailable when using forecast.io

    WeatherCode unavailable when using forecast.io

    It seems to be unimplemented right now, just returning null for everything. From their documentation, it seems that the icon field would be the most suitable for deducing the weather code.

    opened by CJxD 0
  • Yahoo API Endpoints Deprecated

    Yahoo API Endpoints Deprecated

    I have tried to use Yahoo as a provider, and the address seems to be no longer valid. Is there any workaround for this?

    java.net.UnknownHostException: Unable to resolve host "where.yahooapis.com": No address associated with hostname

    @survivingwithandroid

    opened by vdaita 0
  • could not find android in gradle

    could not find android in gradle

    Error:(22, 0) Could not find method android() for arguments [build_cwqu79fqes3pz2wapgwb59gsu$_run_closure3@6b1ace86] on root project 'forecastie-master' of type org.gradle.api.Project. Open File

    opened by Monikarox 1
  • Underground not work

    Underground not work

    { "response": { "version":"0.1", "termsofService":"http://www.wunderground.com/weather/api/d/terms.html", "features": { } , "error": { "type": "invalidquery" ,"description": "you must supply a location query" } } }

    opened by croccio 0
Releases(1.6.0)
Owner
Surviving with android (by Francesco Azzola)
Surviving with android (by Francesco Azzola)
card.io provides fast, easy credit card scanning in mobile apps

card.io SDK for Android card.io provides fast, easy credit card scanning in mobile apps. Stay up to date Please be sure to keep your app up to date wi

card.io 2k Jan 1, 2023
StreamPack: live streaming SDK for Android based on Secure Reliable Transport

StreamPack: live streaming SDK for Android based on Secure Reliable Transport (SRT) StreamPack brings the best audio/video live technologies together

guo shao hong 2 Aug 10, 2022
Peer Support is a community-based peer to peer mental health therapy platform built using Webex Android SDK

Peer Support Peer Support is a community-based peer to peer mental health therapy platform built using Webex Android SDK. Table of Contents Video Demo

Webex Solution Developers 1 Sep 6, 2022
Library for Android In-App Billing (Version 3+)

Checkout (Android In-App Billing Library) Description Checkout is an implementation of Android In-App Billing API (v3+). Its main goal is to make inte

Sergey Solovyev 1k Nov 26, 2022
Donations library for Android. Supports Google Play Store, Flattr, PayPal, and Bitcoin

Android Donations Lib Android Donations Lib supports donations by Google Play Store, Flattr, PayPal, and Bitcoin. It is used in projects, such as Open

Sufficiently Secure 346 Jan 8, 2023
Donations library for Android. Supports Google Play Store, Flattr, PayPal, and Bitcoin

Android Donations Lib Android Donations Lib supports donations by Google Play Store, Flattr, PayPal, and Bitcoin. It is used in projects, such as Open

Sufficiently Secure 345 Dec 21, 2022
Accept PayPal and credit cards in your Android app

Important: PayPal Mobile SDKs are Deprecated. The APIs powering them will remain operational long enough for merchants to migrate, but the SDKs themse

PayPal 802 Dec 22, 2022
A sample project of implementing Liveness Detection and Identity OCR on Android app using Kredibel Vision SDK

Vision Sample (Android) A sample project of implementing Liveness Detection and Identity OCR on Android app using Kredibel Vision SDK. You can checkou

null 10 Nov 27, 2022
Qiscus provide everything you need to power up your app with chats. And it's now made simple.

Introduction Qiscus Chat SDK (Software Development Kit) is a product provided by Qiscus that enables you to embed an in-app chat/chat feature in your

Qiscus - Multichannel Conversational Platform 197 Dec 27, 2022
Android library project for providing multiple image selection from the device.

PolyPicker Android library project for selecting/capturing multiple images from the device. Result Caution! Eclipse library project structure has been

JW 407 Dec 27, 2022
Android library that provides for multiple image selection.

#MultipleImageSelect An android library that allows selection of multiple images from gallery. It shows an initial album (buckets) chooser and then im

Darshan Dorai 299 Nov 14, 2022
A clustering library for the Google Maps Android API v2

DEPRECATED Don't use this. The Maps v3 SDK handles markers. That with a few other cool utilities make this library obsolete! Clusterkraf A clustering

Ticketmaster Mobile Studio 258 Nov 28, 2022
Small library that wraps Google Play Service API in brilliant RxJava Observables reducing boilerplate to minimum.

ReactiveLocation library for Android Small library that wraps Google Play Services API in brilliant RxJava Observables reducing boilerplate to minimum

Michał Charmas 2.1k Dec 4, 2022
this is the demo of billing new library v3

Billing library v3 demo android This is the demo of billing new library v3 for android native IMPORTANT 1- you must have login to google play store to

Muhammad Sikandar 3 Dec 6, 2021
This App is sending Face capture data over network, built around the latest Android Arcore SDK.

AndroidArcoreFacesStreaming From any Android phone ArCore compatible, using this app will send over TCP 5680 bytes messages: The first 5616 bytes is a

Maxime Dupart 30 Nov 16, 2022
How to Integrate SAWO SDK to an Android app

How to Integrate SAWO SDK to an Android app Add following line to root build.gradle repositories block maven { url 'https://jitpack.io' } Add this to

Latiful Mousom 0 Nov 20, 2021
A very simple way to implement In App Purchases on Android.

The Google-developed Android In App Purchases library can seem quite confusing and too much code to do something as simple as making in-app purchases

Maickonn Richard 1 Sep 29, 2021
The client app for Android

handl-service-provider-application “Service Booking Platform ” is an advanced pl

null 0 Dec 20, 2021