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.
Verify that PDE server information is required
Specify the PDE server information
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;
}
}
}
Next topic:
Retrieving a location provider
Previous topic: Specify the GPS mode
by using BlackBerry extensions to JSR 179