The Location API BLACKBERRY

The BlackBerry uses the Java ME Location API to get location information, such as latitude, longitude, altitude, speed, and course (direction). This package is located in javax. microedition. location.

GPS Modes

You can use GPS in three main modes: Cell Site, Assisted GPS, and Unassisted GPS. All are supported by any device that supports GPS (or has an external GPS receiver) though Assisted GPS can only be used where the wireless network supports it. These modes are discussed in the following sections.

Cell Site

The Cell Site mode determines the location of the device solely based on cell tower locations and signal strengths. This provides only location, not speed or other route information. The accuracy is generally poor. Unlike the real GPS methods, it is almost instantaneous.

Assisted GPS

Assisted GPS uses GPS hardware and assistance from the wireless network to do things such as locate the GPS satellites to speed up the satellite acquisition and location process. Generally, this provides high accuracy, and although it is slower than Cell Site location, it is faster than Unassisted GPS location.

Unassisted GPS

Unassisted GPS uses only the GPS hardware for location. This provides a high degree of accuracy, but it might take two minutes or longer to acquire satellite signals and determine the device’s location. Of course, it works whether there is wireless network coverage available to the device or not.

Specifying a GPS Mode

GPS modes are specified using the javax.microedition.location.Criteria class, which enables you to specify the requirements for the location provider. You create an instance of the Criteria class and pass it into javax.microedition.location.LocationProvider.getInstance.

Based on your requirements, the BlackBerry then chooses the appropriate location mode. The BlackBerry Javadocs provide a chart telling you which values determine which mode is used,but it’s helpful to understand what some of the main criteria mean and why they affect location mode.This is discussed in the following sections.

Longitudinal and Latidunal Accuracy

These are specified in metres: horizontal for longitude and vertical for latitude. Cell Site location is the least accurate; Assisted GPS and Unassisted GPS are both accurate:

criteria.setHorizontalAccuracy(accuracy);
criteria.setVerticalAccuracy(accuracy);

If any value is specified for these, Cell Site location is ruled out.

Power Consumption

Specifies the maximum allowable power consumption for location. Cell Site mode requires the lowest power, Assisted GPS requires the highest, and Unassisted GPS is somewhere between them:

criteria.setPreferredPowerConsumption(Criteria.POWER_USAGE_HIGH);

Altitude and Speed and Course

Cell Site location cannot provide either of these, so setting either to true rules it out:

criteria.setAltitudeRequired(true);
criteria.setSpeedAndCourseRequired(true);

Cost

Because Assisted GPS and Cell Site location use wireless networking, data cost might be associated with each. Unassisted GPS doesn’t use the wireless network, so there’s no chance that the user can incur additional costs by using location services, so not allowing cost means that Unassisted GPS is the only choice:

criteria.setCostAllowed(true);

With all of these interacting criteria,there are several ways to select each of the location modes; the following sections provide an example of criteria that will result in each mode being selected.

To Use Cell Site Location

With this criteria, accuracy is not required, cost is allowed, and preferred power consumption is low:

Criteria criteria = new Criteria();
criteria.setHorizontalAccuracy(Criteria.NO_REQUIREMENT);
criteria.setVerticalAccuracy(Criteria.NO_REQUIREMENT);
criteria.setCostAllowed(true);
criteria.setPreferredPowerConsumption(Criteria.POWER_USAGE_LOW);

To Use Assisted GPS Location

With this criteria, accuracy is not required, cost is allowed, and preferred power consumption is medium:

Criteria criteria = new Criteria();
criteria.setHorizontalAccuracy(Criteria.NO_REQUIREMENT);
criteria.setVerticalAccuracy(Criteria.NO_REQUIREMENT);
criteria.setCostAllowed(true);
criteria.setPreferredPowerConsumption(Criteria.POWER_USAGE_MEDIUM);

To Use Assisted and Unassisted Modes

With this criteria, the initial location is retrieved using Assisted GPS; subsequent locations are fully unassisted.Accuracy is 50 metres, cost is allowed, and preferred power consumption is high:

Criteria criteria = new Criteria();
criteria.setHorizontalAccuracy(50);
criteria.setVerticalAccuracy(50);
criteria.setCostAllowed(true);
criteria.setPreferredPowerConsumption(Criteria.POWER_USAGE_HIGH);

To Use Only Unassisted Mode

Unassisted GPS is used for the first and all subsequent location retrievals. Accuracy is 50 meters, cost is not allowed, and power consumption is high or at no requirement:

Criteria criteria = new Criteria();
criteria.setHorizontalAccuracy(50);
criteria.setVerticalAccuracy(50);
criteria.setCostAllowed(false);
criteria.setPreferredPowerConsumption(Criteria.POWER_USAGE_HIGH);

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

BLACKBERRY Topics