This example shows you how to create a simple location-aware weather
forecast MIDlet that also supports in-app advertising. 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 addition, the MIDlet employs in-app advertising
in the form of banners and full-screen ads.
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
Implement in-app advertising
The MIDlet has been designed to work especially on various Series 40 devices with different form factors and input methods.
Figure: WeatherApp MIDlet
For a tutorial that shows you how to create this MIDlet, see section Example: Creating a weather forecast MIDlet with in-app advertising support.
This MIDlet is provided in two versions:
The regular version is compatible with Series 40 3rd Edition and S60 3rd Edition devices and newer.
The Series 40 full touch version is compatible with Series 40 3rd Edition and S60 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 701 (Symbian Belle with Java Runtime 2.3 for Symbian)
Nokia 2730 Classic (Series 40 5th Edition FP1)
Nokia 3110 Classic (Series 40 3rd Edition FP2)
Nokia 6280 (Series 40 3rd Edition)
Nokia Asha 200 (Java Runtime 1.1.0 for Series 40)
Nokia Asha 303 (Java Runtime 1.1.0 for Series 40)
Nokia Asha 306 (Java Runtime 2.0.0 for Series 40)
Nokia Asha 311 (Java Runtime 2.0.0 for Series 40)
Nokia C1-01 (Series 40 6th Edition Lite)
Nokia E61i (S60 3rd Edition)
Nokia E6-00 (Symbian Anna with Java Runtime 2.2 for Symbian)
Nokia E7-00 (Symbian Anna with Java Runtime 2.2 for Symbian)
Nokia X3-02 (Series 40 6th Edition FP1)
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 earlier versions of the MIDlet, see the Nokia Developer Project.
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