Retrieve location information from GPS satellites using PDE

  1. Import the following classes:
    • javax.microedition.location.LocationProvider
    • javax.microedition.location.Criteria
  2. Create an instance of a Criteria object.
    Criteria criteria = new Criteria();
  3. Invoke criteria.setHorizontalAccuracy(NO_REQUIREMENT) to specify that longitudinal accuracy is not required.
  4. Invoke criteria.setVerticalAccuracy(NO_REQUIREMENT) to specify that latitudinal accuracy is not required.
  5. Invoke criteria.setCostAllowed(true) to specify that this mode can incur costs for the BlackBerry® device user.
  6. Invoke criteria.setPreferredPowerConsumption(int level) using either POWER_USAGE_MEDIUM, or NO_REQUIREMENT as the parameter to specify power consumption is medium or not required.
  7. Invoke LocationProvider.getInstance(), storing the returned object in a LocationProvider object.
    LocationProvider provider = LocationProvider.getInstance(criteria);

Was this information helpful? Send us your comments.