We are excited to announce support for 3rd party app access to BerryWeather data in BerryWeather 2.2. This allows any developer to easily access BerryWeather's home location conditions via a simple interface to use in their own apps.
BerryWeather exports the data as a Hashtable stored in a RuntimeStore. The guid of the RuntimeStore is
0x7f0ad179383f30edL. The Hashtable will be empty if there is currently no data available (this will usually happen after boot before all locations have been updated).
If no data is available in the RuntimeStore (it returns NULL) this means BerryWeather has not been installed on the device or the version installed does not support 3rd party apps (all versions before 2.2). You can direct users to
http://m.bellshare.com/berryweather for download of the latest version
The RuntimeStore can be accessed as follows:
Code:
private static final long ExportRuntimeStoreId = 0x7f0ad179383f30edL;
Object d = RuntimeStore.getRuntimeStore().get(BerryWeatherHelper.ExportRuntimeStoreId);
if(d != null && d instanceof Hashtable)
{
Data = (Hashtable) d;
}
else
{
Data = null;
}
The returned Hashtable will contain the following keys. Please be aware that any of the values might be NULL:
icon - Bitmap, current condition icon of home location
iconscaled - Bitmap, current condition icon of home location scaled as set by "wallpaper icon size" in BerryWeather settings
name - String, name of home location
conditions - String, current sky conditions (Clear, Sunny etc) of home location
temperature - String, current temperature of home location
temperaturelow - String, low temperature of home location
temperaturehigh - String, high temperature of home location
observed - String, observation time of conditions for home location
observedepoch - Integer, Observation time in Unix epoch
feelslike - String, feels like temperature for home location
iconname - String, name of condition icon of home location
The RuntimeStore will update whenever BerryWeather downloads new data for the home location. If you want to be notified of any changes in the data you can listen for a global event. The guid of the global event is
0x37b66763f3b37dbdLTo listen for the event you have to implement the GlobalEventListener interface and register a global event listener:
Code:
private static final long GlobalEventExportRuntimeStoreUpdated = 0x37b66763f3b37dbdL;
Application.addGlobalEventListener( this );
public void eventOccurred( long guid, int data0, int data1, Object object0, Object object1 ) {
if( guid == GlobalEventExportRuntimeStoreUpdated ) {
// access data via RuntimeStore or use (Hashtable)object0
}
}
The Hashtable stored in the RuntimeStore will also be passed as object0 in the global event.
If you have any further questions post here or contact me directly via PM.