This example shows you how to create a simple location-aware weather
forecast MIDlet. The MIDlet shows a four-day forecast with temperatures,
relative humidity, wind speed, and wind direction. The MIDlet retrieves
the weather forecast information based on the device's current location,
which the MIDlet determines using either cell ID or GPS positioning.
The user can also explicitly specify the location for which to retrieve
the weather forecast information. The MIDlet uses World Weather
Online APIs for retrieving both weather data and location search
data, and the org.json.me
library for parsing
the JavaScript Object Notation (JSON) values returned by the World
Weather Online APIs.
In short, this example demonstrates how to:
Use the Location API for cell ID and GPS positioning
Use World Weather Online APIs for retrieving weather and location search data
Parse JSON values
The MIDlet has been designed to work especially on various Series 40 devices with different form factors and input methods.
Figure: WeatherApp MIDlet running on a Series 40 full touch device
For a tutorial that shows you how to create this MIDlet, see section Example: Creating a weather forecast MIDlet.
This MIDlet is provided in two versions:
The regular version is compatible with Series 40 3rd Edition devices and newer.
The Series 40 full touch version is compatible with Series 40 3rd Edition devices and newer, but the Series 40 full touch features are only available on Series 40 full touch devices with Java Runtime 2.0.0 for Series 40 or newer.
Note: The MIDlet must be compiled with Nokia SDK 1.0 for Java
or newer, since the MIDlet uses the LocationUtil
class,
which is supported from Java Runtime 1.0.0 for Series 40 onwards.
This MIDlet has been tested on the following devices:
Nokia 2730 Classic (Series 40 5th Edition Feature Pack 1)
Nokia 3110 Classic (Series 40 3rd Edition Feature Pack 2)
Nokia 6280 (Series 40 3rd Edition)
Nokia Asha 200 on Nokia Asha software platform (Java Runtime 1.1.0 for Series 40)
Nokia Asha 303 on Nokia Asha software platform (Java Runtime 1.1.0 for Series 40)
Nokia Asha 306 on Nokia Asha software platform (Java Runtime 2.0.0 for Series 40)
Nokia Asha 311 on Nokia Asha software platform (Java Runtime 2.0.0 for Series 40)
Nokia C1-01 (Series 40 6th Edition Lite)
Nokia X3-02 (Series 40 6th Edition Feature Pack 1)
The MIDlet project files are packaged as a zip file. The zip file includes two projects: the regular version and the Series 40 full touch version. To download the zip file, click the following link:
For possible newer version, other updates or additional documentation, check the WeatherApp at Nokia Developer Projects.
The MIDlet consists of the following packages and classes (click to view the full source code):
Note: The source code is from the Series 40 full touch version of the MIDlet. To view the source code of the regular version, see the source code files in the zip file.
com.nokia.example.weatherapp
com.nokia.example.weatherapp.ads
com.nokia.example.weatherapp.components
com.nokia.example.weatherapp.helpers
com.nokia.example.weatherapp.location
com.nokia.example.weatherapp.network
com.nokia.example.weatherapp.orientation
com.nokia.example.weatherapp.resources
com.nokia.example.weatherapp.views