Specify the GPS mode (JSR 179)

The JSR 179 Location API is supported on BlackBerry® devices that run BlackBerry® Device Software 4.0.2 or later.

  1. Import the required class.
    import javax.microedition.location.Criteria;
  2. Create a class and constructor.
    public class handleGPS
    {
        public handleGPS()
        {
        }
    }
  3. In the constructor, create an instance of the Criteria class. Create a variable to specify a GPS mode.
    Criteria myCriteria = new Criteria();
    int myMode = 2; // AUTONOMOUS
  4. In the constructor, map the properties for each GPS mode by invoking the corresponding set method for each property.
    switch ( myMode )
    {
        case 0: // CELLSITE
            myCriteria.setPreferredPowerConsumption(Criteria.POWER_USAGE_LOW);
            myCriteria.setHorizontalAccuracy(Criteria.NO_REQUIREMENT);
            myCriteria.setVerticalAccuracy(Criteria.NO_REQUIREMENT);
            myCriteria.setCostAllowed(true);
            break;
    
        case 1: // ASSIST
            myCriteria.setPreferredPowerConsumption(Criteria.POWER_USAGE_MEDIUM);
            myCriteria.setHorizontalAccuracy(100);
            myCriteria.setVerticalAccuracy(100);
            myCriteria.setCostAllowed(true);
            break;
    
        case 2: // AUTONOMOUS
            myCriteria.setCostAllowed(false);
            break;
    }

Was this information helpful? Send us your comments.