This sample Blackberry application demonstrates an approach for GPS functionality usage.
private GPSLocator gpsLocator; ... gpsLocator = new GPSLocator();
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()); } }
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.
-
addStateListener(GPSStateListener listener)
-
removeStateListener(GPSStateListener listener)
-
addLocationListener(GPSLocationListener listener)
-
removeLocationListener(GPSLocationListener listener)
To see an example please launch GPSDemoApplication in your BlackBerry device simulator.