Troubleshooting guide
205
14: Using location information
Requirements for retrieving GPS location information from BlackBerry devices
that run on the CDMA network
If you create applications for the BlackBerry® 7250 Wireless Handheld™ and the BlackBerry 7130e™ devices that
require location information, you must obtain a unique PDE IP and port number from the CDMA wireless service
provider for those BlackBerry devices. The PDE provides a BlackBerry device with initial ephemeris and almanac
data when a BlackBerry device user starts an application that uses the Location API.
Before your application accesses the Location API, you must make sure that your application sends the PDE IP and
port number to the wireless transceiver of the BlackBerry device. If an application on a CDMA device attempts to
access the Location API without providing the correct PDE information to the wireless transceiver of the
BlackBerry device, the application cannot obtain location information.
Register a location listener. You can associate only one location listener with a particular GPS location provider. Applications
typically listen for updates on a separate thread.
1. Implement the LocationListener interface.
2. Register your implementation by invoking
LocationProvider.setLocationListener().
import javax.microedition.LocationProvider.*;
public class SampleLocationApp {
public static void main (string[] Args) {
// ...
provider.setLocationListener(new SampleLocationListener(), 0, 60, 60);
}
}
class SampleLocationListener implements LocationListener {
void locationUpdated(LocationProvider provider, Location location) {
// Respond to the updated location.
// If the application registered the location listener with an interval
of
// 0, the location provider does not provide location updates.
}
void providerStateChanged(LocationProvider provider, int newState) {
switch (newState) {
case LocationProvider.AVAILABLE :
// The location provider is available.
break;
case LocationProvider.OUT_OF_SERVICE :
// The location provider is permanently unavailable.
// Consider cancelling the location listener by calling
// provider.setLocationListener() with null as the listener.
break;
case LocationProvider.TEMPORARILY_UNAVAILABLE :
// The location provider is temporarily unavailable.
break;
}
}
}
Task Steps