Development Guide

Local Navigation

Retrieving location information by using the assisted GPS mode

Assisted mode using a PDE server

The assisted mode can be used with BlackBerry devices that are associated with a CDMA network that utilizes PDE server technology. The assisted mode is designed to provide fast retrieval of a GPS fix.

Assisted GPS capabilities are currently defined by wireless service providers. In many instances, you must enter into a formal relationship with wireless service providers before you can connect to their PDE server.

Back To Top

Verify that PDE server information is required

Before using assisted mode with a PDE server, you must verify whether PDE server information is required.

  1. Import the required class.
    import net.rim.device.api.gps.GPSSettings;
  2. Create a class and constructor. In the constructor, invoke isPDEInfoRequired() to verify if you need to specify the PDE server information to use assisted mode.
    public class checkPDE
    {
       public checkPDE()
       {
          if ( isPDEInfoRequired(GPSInfo.GPS_MODE_ASSIST))
          {
              // set up PDE server access
          }
       }
    }
Back To Top

Specify the PDE server information

Before you begin:

You must have the user ID, password, IP address and port number that the wireless service provider uses for their PDE server.

  1. Import the required classes.
    import net.rim.device.api.gps.*;
    import javax.microedition.location.*;
  2. Create a class and a constructor.
    public class handleGPS
    {
        static GPSThread gpsThread;
    
        public handleGPS()
        {
        }
    }
  3. In the constructor, create and start an instance of the Thread class.
    gpsThread = new GPSThread();
    gpsThread.start();
  4. In the class, create a private static class that extends Thread, and create a run() method.
    private static class GPSThread extends Thread
    {
       public void run()
       {
       }
    }
  5. In the run() method of the private class, invoke isGPSModeAvailable() passing GPS_MODE_ASSIST as a parameter to determine if the assisted mode is available on the BlackBerry device. Invoke isPDEInfoRequired() to determine if you need to specify PDE server information. If PDE server information is required, create an instance of the BlackBerryCriteria class by passing GPS_MODE_ASSIST as a parameter to the constructor.
    if ( !GPSInfo.isGPSModeAvailable(GPSInfo.GPS_MODE_ASSIST) ||
        !GPSSettings.isPDEInfoRequired(GPSInfo.GPS_MODE_ASSIST))
        return;
    
    BlackBerryCriteria myCriteria = new BlackBerryCriteria
      (GPSInfo.GPS_MODE_ASSIST);
  6. In the run() method of the private class, create a try/catch block. In the block, associate an instance of the BlackBerryCriteria class with a BlackBerryLocationProvider object. Create and specify the user ID, password, and IP address String objects, and the port ID. Combine the String objects into a single String. Invoke setPDEInfo()to specify the PDE server IP address and port number of the BlackBerry device.
    try
    {
        BlackBerryLocationProvider myProvider =
          (BlackBerryLocationProvider)
          LocationProvider.getInstance(myCriteria);
        String user = "UserID";
        String pass = "Password";
        String ip = "127.0.0.1";
        int port = 0;
        String str = ip + ";" + user + ";" + pass;
        GPSSettings.setPDEInfo(str, port);
    
        try
        {
            BlackBerryLocation myLocation =
              (BlackBerryLocation)myProvider.getLocation(10);
        }
        catch ( InterruptedException iex )
        {}
        catch ( LocationException lex )
        {}
    }
    catch ( LocationException lex )
    {}
    
    return;
Back To Top

Code sample: Specifying the PDE server information

import net.rim.device.api.gps.*;
import javax.microedition.location.*;

public class handleGPS
{
    static  GPSThread gpsThread;

    public handleGPS()
    {
        gpsThread = new GPSThread();
        gpsThread.start();
    }

    private static class GPSThread extends Thread
    {
        public void run()
        {
            if ( !GPSInfo.isGPSModeAvailable(GPSInfo.GPS_MODE_ASSIST) ||
                !GPSSettings.isPDEInfoRequired(GPSInfo.GPS_MODE_ASSIST))
                return;

            BlackBerryCriteria myCriteria =
                new BlackBerryCriteria(GPSInfo.GPS_MODE_ASSIST);

            try
            {
                BlackBerryLocationProvider myProvider = 
                  (BlackBerryLocationProvider)
                  LocationProvider.getInstance(myCriteria);
                String user = "UserID";
                String pass = "Password";
                String ip = "127.0.0.1";
                int port = 0;
                String str = ip + ";" + user + ";" + pass;
                GPSSettings.setPDEInfo(str, port);

                try
                {
                    BlackBerryLocation myLocation =
                      (BlackBerryLocation)myProvider.getLocation(10);
                }
                catch ( InterruptedException iex )
                {
                    return;
                }
                catch ( LocationException lex )
                {
                    return;
                }
            }
            catch ( LocationException lex )
            {
                return;
            }
            return;
        }
    }
}
Back To Top

Was this information helpful? Send us your comments.