/blackberry_gps

A framework aimed to simplify developing GPS enabled applications. An example application is included.

Primary LanguageJava

DESCRIPTION

This sample Blackberry application demonstrates an approach for GPS functionality usage.

USAGE

Define the GPSLocator object in your application

private GPSLocator gpsLocator;
...
gpsLocator = new GPSLocator();

Initialize the locator object when it is needed.

public static final int LOCATION_UPDATE_INTERVAL   = 5;
public static final int LOCATION_UPDATE_TIMEOUT    = 5;
public static final int LOCATION_UPDATE_MAXAGE     = -1; //use default values
private void startGPSListening() {
      try {
          gpsLocator.init(null, LOCATION_UPDATE_INTERVAL, LOCATION_UPDATE_TIMEOUT, LOCATION_UPDATE_MAXAGE);
      } catch (GPSException e) {
          alert(e.getMessage());
      }
  }

Implement the GPSLocationListener or GPSStateListener interface in your classes.

public void gpsLocationUpdated(Location newLocation)

Will be called periodically (according to LOCATION_UPDATE_INTERVAL) to provide updates of the current location.

public void gpsStateChanged(int newState)

Will be called after changes of the locator’s state.

Use GPSLocator’s methods to add or remove appropriate listeners

  • addStateListener(GPSStateListener listener)

  • removeStateListener(GPSStateListener listener)

  • addLocationListener(GPSLocationListener listener)

  • removeLocationListener(GPSLocationListener listener)

EXAMPLES

To see an example please launch GPSDemoApplication in your BlackBerry device simulator.