我正在開發基於GPS的應用程序。我使用LocationProvider,並通過它的代碼調用setlocationListener就像setLocationListener不工作在黑莓GPS編程
LocationProvider lp = LocationProvider.getInstance(null);
if (lp != null) {
lp.setLocationListener(new LocationListenerImpl(), 2, 1, 1);
} else {
Dialog.alert("GPS NOT SUPPORTED!");
retval = false;
}
} catch (LocationException e) {
System.out.println("GPS Error: " + e.toString());
}
return retval;
}
private class LocationListenerImpl implements LocationListener {
public void locationUpdated(LocationProvider provider, Location location) {
if (location.isValid()) {
heading = location.getCourse();
longitude = location.getQualifiedCoordinates().getLongitude();
latitude = location.getQualifiedCoordinates().getLatitude();
altitude = location.getQualifiedCoordinates().getAltitude();
speed = location.getSpeed();
System.out.println("Current latitude:"+latitude);
System.out.println("Current longitude:"+longitude);
System.out.println("Current speed:"+speed);
// This is to get the Number of Satellites
String NMEA_MIME = "application/X-jsr179-location-nmea";
satCountStr = location.getExtraInfo("satellites");
if (satCountStr == null) {
satCountStr = location.getExtraInfo(NMEA_MIME);
}
// this is to get the accuracy of the GPS Cords
QualifiedCoordinates qc = location.getQualifiedCoordinates();
accuracy = qc.getHorizontalAccuracy();
}
}
它不給出一個錯誤,但甚至不工作了所以用same.the控制不得到轉移到LocationListenerImpl幫助() ... 我在黑莓8800模擬器上使用BlackBerry_JDE_PluginFull_1.0.0.67與eclipse-java-galileo-SR1-win32 .. 任何協助感謝.... 感謝您提前。
你接受了一個答案或仍然需要任何幫助! – Swati 2010-06-17 10:15:46