Development Guide

Local Navigation

Specifying the GPS mode by using BlackBerry extensions to JSR 179

The BlackBerry extensions to JSR 179 provide an enhanced set of GPS criteria. The net.rim.device.api.gps.BlackBerryCriteria class extends the javax.microedition.location.Criteria class. You can use the methods in the BlackBerryCriteria class to specify the GPS requirements for your application.

Method

Description

setMode(int)

You can use this method to specify an initial GPS mode when you create a BlackBerryCriteria object.

setFailoverMode(int, int, int)

You can use this method to specify a GPS failover mode to use when the initial GPS mode is unsuccessful. This method applies only to the internal GPS functionality on a BlackBerry device.

setSubsequentMode(int)

You can use this method to specify a subsequent GPS mode to use after a successful first GPS fix is retrieved.

setGPSRestartInterval(int, int)

You can use this method to specify an interval to wait before automatically restarting the GPS retrieval process when a GPS fix is not successfully retrieved. You can specify intervals to a maximum of 15 minutes and a minimum of 2 seconds, with a limit of three automatic retries.

setSatelliteInfoRequired(boolean, boolean)

You can use this method to specify whether you want satellite tracking information. The satellite tracking information consists of the number of satellites in view, and their IDs, signal quality, elevation, and azimuth. This applies only to the internal GPS functionality on a BlackBerry device.

Specify the GPS mode by using BlackBerry extensions to JSR 179

The BlackBerry extensions to JSR 179 are supported on BlackBerry devices that run BlackBerry Device Software 5.0.0 or later.

  1. Import the required class.
    import net.rim.device.api.gps.*;
  2. Create a class and constructor.
    public class handleGPS
    {
        BlackBerryCriteria myCriteria;
    
        public handleGPS()
        {
        }
    }
  3. In the constructor, create a try/catch block. In this block, create an instance of the BlackBerryCriteria class by passing the GPS mode as a parameter to the constructor.
    try
    {
        myCriteria = new BlackBerryCriteria(GPSInfo.GPS_MODE_ASSIST);
    }
    catch ( UnsupportedOperationException ex )
    {
        return;
    }
  4. In the constructor, invoke setFailloverMode() to specify the GPS failover mode to use if the first GPS mode that you specify cannot retrieve a GPS fix. Invoke setSubsequentMode() to specify a subsequent GPS mode to use after a successful first fix is retrieved.
    myCriteria.setFailoverMode(GPSInfo.GPS_MODE_AUTONOMOUS, 3, 100);
    myCriteria.setSubsequentMode(GPSInfo.GPS_MODE_AUTONOMOUS);
  5. To verify if a GPS mode is supported, invoke GPSInfo.isGPSModeAvailable() and pass the GPS mode as a parameter. Invoke setMode() to specify the GPS mode, if the mode is supported.
    public class handleGPS
    {
        public handleGPS()
        {
            BlackBerryCriteria myCriteria = new BlackBerryCriteria();
    
            if (GPSInfo.isGPSModeAvailable(GPSInfo.GPS_MODE_ASSIST))
                myCriteria.setMode(GPSInfo.GPS_MODE_ASSIST);
            else if (GPSInfo.isGPSModeAvailable(GPSInfo.GPS_MODE_AUTONOMOUS))
                myCriteria.setMode(GPSInfo.GPS_MODE_AUTONOMOUS);
        }
    }
Back To Top

Was this information helpful? Send us your comments.