Troubleshooting guide
202
BlackBerry Java Development Environment Development Guide
Selecting a GPS location provider
Specify the desired criteria by creating an instance of the javax.microedition.location.Criteria class,
invoking the appropriate
set methods, and then passing the instance to LocationProvider.getInstance().
The GPS location provider is selected depending on how closely the GPS location provider matches the defined
criteria.
Specify criteria for selecting a GPS location provider
Assisted GPS_AID_MODE_ASSIST The assisted method uses the wireless network to provide ephemeris GPS satellite data to
the BlackBerry® device chip.
Advantages
• Provides the GPS location faster than the autonomous method and more accurately
than the cellsite method.
Requirements
• Requires network connectivity and wireless service provider support.
Autonomous GPS_AID_MODE_AUTONOMOUS The autonomous method uses the GPS chip on the BlackBerry device without assistance
from the wireless network.
Advantages
• Does not require assistance from the wireless network.
Disadvantages
• Is the slowest location method.
Note: To create a LocationProvider instance with default criteria, invoke LocationProvider.getInstance(null).
Task Steps
Create selection criteria. > Create an instance of a Criteria object.
Criteria criteria = new Criteria();
Set whether BlackBerry® device users
can incur cost.
>Invoke setCostAllowed().
criteria.setCostAllowed(true);
Set required horizontal accuracy. >Invoke setHorizontalAccuracy().
criteria.setHorizontalAccuracy(50);
Set required vertical accuracy. >Invoke setVerticalAccuracy().
criteria.setVerticalAccuracy(50);
Provide criteria to the GPS location
provider.
>Invoke LocationProvider.getInstance(), storing the returned object in a
LocationProvider object.
LocationProvider provider = LocationProvider.getInstance(criteria);
Recommended GPS location method Horizontal accuracy Vertical accuracy Cost Power consumption
autonomous required required not allowed not applicable
Method Constant Description