Specify the GPS mode
by using BlackBerry extensions to JSR 179
The BlackBerry® extensions to JSR 179 are supported on BlackBerry devices that run BlackBerry®
Device Software 5.0.0 or later.
-
Import the required class.
import net.rim.device.api.gps.*;
- Create a class and constructor.
public class handleGPS
{
BlackBerryCriteria myCriteria;
public handleGPS()
{
}
}
- In the constructor, create a try/catch block. In this block, create an instance of the BlackBerryCriteria class by passing the GPS mode as a parameter to the constructor.
try
{
myCriteria = new BlackBerryCriteria(GPSInfo.GPS_MODE_ASSIST);
}
catch ( UnsupportedOperationException ex )
{
return;
}
- In the constructor, invoke setFailloverMode() to specify the GPS failover mode to use if the first GPS mode that you specify cannot retrieve a GPS fix. Invoke setSubsequentMode() to specify a subsequent GPS mode to use after a successful first fix is retrieved.
myCriteria.setFailoverMode(GPSInfo.GPS_MODE_AUTONOMOUS, 3, 100);
myCriteria.setSubsequentMode(GPSInfo.GPS_MODE_AUTONOMOUS);
- To verify if a GPS mode is supported, invoke GPSInfo.isGPSModeAvailable() and pass the GPS mode as a parameter. Invoke setMode() to specify the GPS mode, if the mode is supported.
public class handleGPS
{
public handleGPS()
{
BlackBerryCriteria myCriteria = new BlackBerryCriteria();
if (GPSInfo.isGPSModeAvailable(GPSInfo.GPS_MODE_ASSIST))
myCriteria.setMode(GPSInfo.GPS_MODE_ASSIST);
else if (GPSInfo.isGPSModeAvailable(GPSInfo.GPS_MODE_AUTONOMOUS))
myCriteria.setMode(GPSInfo.GPS_MODE_AUTONOMOUS);
}
}
Was this information helpful? Send us your comments.