Blackberry GPS and BlackBerry Maps Handbuch - Seite 8
Blättern Sie online oder laden Sie pdf Handbuch für Software Blackberry GPS and BlackBerry Maps herunter. Blackberry GPS and BlackBerry Maps 35 Seiten. Version: 4.7.0
Development Guide
Task
Specify a level of accuracy,
with no cost and variable
power consumption.
3.
Invoke LocationProvider.getInstance(), storing the returned object in a LocationProvider object.
LocationProvider provider = LocationProvider.getInstance(criteria);
Getting GPS location information
Specify a response time for getting the location of the BlackBerry device
Invoke Criteria.setPreferredResponseTime(), and specify the response time, in milliseconds.
Get the location information for a BlackBerry device
In a non-event thread, invoke LocationProvider.getLocation(int), providing a timeout, in seconds.
try {
// Specify -1 to have the implementation use its default timeout value
// for this provider.
Location location = provider.getLocation(-1);
} catch (Exception e) {
// handle LocationException, InterruptedException, SecurityException
// and IllegalArgumentException
}
Get the speed of the BlackBerry device, in meters per second
Invoke location.getSpeed().
Location location = provider.getLocation(-1);
float speed = mylocation.getSpeed();
6
Steps
a.
Invoke criteria.setHorizontalAccuracy(NO_REQUIREMENT).
b.
Invoke criteria.setVerticalAccuracy(NO_REQUIREMENT).
c.
Invoke criteria.setCostAllowed(false).
d.
Invoke
criteria.setPreferredPowerConsumption(int level) using
one of POWER_USAGE_MEDIUM, POWER_USAGE_HIGH, or
NO_REQUIREMENT as the parameter.
Getting GPS location information