【发布时间】:2012-05-15 20:05:51
【问题描述】:
在模拟器中,我的 gps 代码工作正常。但是当我在设备中安装我的应用程序时,我无法获得当前的纬度和经度。
当我从模拟器发送 lat long 时,它会得到通过模拟器发送的正确 lat long。我不知道为什么在设备上不工作?
我已经从 Option > Advance option > gps > gps servce 启用并将位置设置为 ON。
是否有任何其他设置可以获取设备中的当前位置?
private boolean currentLocation() {
boolean retval = true;
try {
LocationProvider lp = LocationProvider.getInstance(null);
if (lp != null) {
lp.setLocationListener(new LocationListenerImpl(), interval, 1, 1);
} else {
// GPS is not supported, that sucks!
// Here you may want to use UiApplication.getUiApplication() and post a Dialog box saying that it does not work
retval = false;
}
} catch (LocationException e) {
System.out.println("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();
// 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();
}
}
【问题讨论】:
-
您使用哪种类型的位置提供程序(自主、蜂窝站点、辅助)?
-
我有 Storm 2,我正在使用 wi-fi。我正在使用 LocationProvider 类
-
你没有回答我的问题......可能只是发布你的代码。
-
也许你正在办公室里测试它,当然没有gps信号;你用 bb 地图知道你的位置吗?
-
是的,我正在办公室测试。我怎样才能测试它是否正常工作?
标签: blackberry gps blackberry-storm