任何人都可以請告訴我如何使用黑莓基於位置的服務? 我正在爲黑莓手機應用程序開發一個項目。我從來沒有黑莓,我沒有任何提供商的合同(只有3卡和移動設備9000操作系統4.6的SIM卡)。黑莓基於位置的服務
在項目中,我目前正嘗試使用以下代碼以檢索當前位置(起點)和目標位置(終點)的座標。它在模擬器上工作得很好,但在設備上什麼也沒有。我應該與供應商簽訂合同嗎?這是否只需要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();
預先感謝您
有些解釋在這裏會有所幫助。 –