Java ME Compass example targeted especially to Series 40 GPS enabled devices. This is a simple application to demonstrate GPS features in Nokia devices.
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
Application Descriptor

Compass JME

This Java ME application demonstrates the Location API and Scalable 2D Vector Graphics API features on the Series 40 devices.

The example is a simple compass which shows the direction of North and the direction of a selected landmark. The user can also add the current location as a landmark.

  1. Prerequisites

Java ME basics

  1. Important files and classes

  • src\..\

  • src\..\

  • src\..\

  • src\..\

  • res\compass.svg

  • res\navi.svg

Classes: LocationProvider, Location, LandmarkStore, Landmark, SVGMatrix.

  1. Design considerations

The application calculates the direction by requesting the course. This means that the correct direction is not immediately shown and the user has to walk a bit for the GPS to get the proper course. This is done because current Nokia phones don't implement the orientation features in the Location API.

When the GPS polling is running, the application uses quite a lot of power. To prevent excess power consumption, the application stops the polling when the backlight goes off or the screensaver goes on. The polling begins again when the backlight goes on or the screensaver goes off.

The SVG images that are manipulated in this example are made a bit differently than usual. The image is actually in the top left corner of the SVG viewport. This is because otherwise the image would rotate with the centerpoint in the top left corner of the image. With the image in the top left corner, the rotation works properly and the only thing left to do is translate the image back to the center of the viewport.

  1. Known issues

No known issues

  1. Build and installation instructions

The example has been made with NetBeans 6.8 and Series 40 6th Edition SDK. The project can be easily opened in NetBeans by selecting Open Project from the File menu and selecting the application.

Before opening the project, make sure a compatible SDK (for example, the Series 40 6th Edition SDK) is installed and added to NetBeans. Building is done by selecting Build main project.

Installing the application on a phone can be done by transfering the JAR file via Nokia Ovi Suite or via Bluetooth on Series 40 devices.

  1. Running the example

The application has two views. The main view shows the direction and the currently selected landmark. You can switch the current landmark by pressing left or right.

The second view is for adding landmarks. To open it, press the left softkey which opens the Store Location view. Pressing up or down highlights the text field and pressing the middle softkey opens a text editor where you can type the name of the new landmark. To get back, press the right softkey.

Getting the correct direction requires the user to walk for a while so that GPS is able to determine the correct course.

  1. Compatibility

Series 40 6th Edition

Tested on:

  • Nokia 2710 Navigation Edition

Developed with:

  • Netbeans 6.8
  • Series 40 6th Edition SDK
  1. Version history

1.0 First Release

  1. Related Documenation

  • Location Services in the Java Developer's Library
  • Scalable 2D Vector graphics in the Java Developer's Library