Location services - WeatherApp

Description

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.

Compatibility

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)

MIDlet project

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:

Download WeatherApp

Table: MIDlet details (regular version)

MIDlet version

1.2.0

Creation date

28 May 2012

IDE

Eclipse and NetBeans

SDK

Nokia SDK 1.1 for Java

Table: MIDlet details (Series 40 full touch version)

MIDlet version

1.2.0

Creation date

28 May 2012

IDE

Eclipse and NetBeans

SDK

Nokia SDK 2.0 for Java

For earlier versions of the MIDlet, see the Nokia Developer Project.

MIDlet classes

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.