Example: Creating a weather forecast MIDlet

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. You 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

Prerequisites

You need the following to develop and test this MIDlet:

For instructions on how to get started with Java ME, see section Getting started.

Development

For more information about the MIDlet, see:

  • Design for information about the design and functionality of the MIDlet

  • Implementation for information about implementing the MIDlet