Troubleshooting guide
206
BlackBerry Java Development Environment Development Guide
Send required PDE data to BlackBerry devices that run on the CDMA network
Before your application tries to use the Location API, send your PDE data to the wireless transceiver of the
BlackBerry device by invoking the
setPDEInfo(String ip, int port) method of the GPSSettings class (see
the net.rim.device.api.gps package), using as parameters the PDE IP and port number that the CDMA wireless
service provider provides to you.
Code sample: Recording GPS information for a BlackBerry device
Example: Subset of GPSDemo.java
/**
* A GPS sample application using the JSR 179 APIs.
*
* Copyright (C) 2005 Research In Motion Limited.
*/
package com.rim.samples.docs.gpsdemo;
import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.io.*;
import net.rim.device.api.system.*;
import net.rim.device.api.i18n.*;
import javax.microedition.io.*;
import java.util.*;
import java.io.*;
import javax.microedition.location.*;
import net.rim.device.api.util.*;
import com.rim.samples.docs.resource.*;
/* This application acts as a simple travel computer, recording route coordinates,
* speed, and altitude.
* Recording begins as soon as the application is invoked.
*/
public class GPSDemo extends UiApplication implements GPSDemoResResource
{
// Constants. ----------------------------------------------------------------
// The number of updates in seconds over which the altitude is calculated.
private static final int GRADE_INTERVAL=5;
// com.rim.samples.docs.gpsdemo.GPSDemo.ID
private static final long ID = 0x4e94d9bc9c54fed3L;
private static final int CAPTURE_INTERVAL=10;
private static final int SENDING_INTERVAL=100;
// Statics. ------------------------------------------------------------------
private static ResourceBundle _resources =
ResourceBundle.getBundle(GPSDemoResResource.BUNDLE_ID, GPSDemoResResource.BUNDLE_NAME);
private static String _hostName = “<fill in the addres of the server here>:5555”;
private static int _interval = 1; //seconds - this is the period of position query
private static Vector _previousPoints;