【发布时间】:2011-08-02 01:36:11
【问题描述】:
谁能告诉我如何使用黑莓定位服务? 我正在开发一个黑莓手机应用程序的项目。我以前从未有过黑莓,也没有与任何供应商签订合同(只有一张来自 3 的 sim 卡和移动设备 9000 OS 4.6)。
在项目中,我目前正在尝试使用以下代码来检索当前位置(起点)和目标位置(终点)的坐标。它在模拟器上工作得很好,但在设备上什么也没有。我应该与供应商签订合同吗?这是否只需要 GPS 或互联网,或两者都可以工作?
代码:
String destination = "London";
final Landmark[] landmarks = Locator.geocode(destination.replace('\n', ' '), null);
Coordinates endPoint = landmarks[0].getQualifiedCoordinates();
// Get a location provider.
LocationProvider provider = LocationProvider.getInstance(null);
if (provider == null)
{
throw new IllegalStateException("No LocationProvider Available!!");
}
// Try to fetch the current location and get the coordinates of the current location.
Coordinates startPoint = provider.getLocation(-1).getQualifiedCoordinates();
double destiinationlatitude = endPoint.getLatitude();
double currentlatitude = startPoint.getLatitude();
提前谢谢你
【问题讨论】:
标签: blackberry