0

如何在黑莓应用程序中从 GPS 获取当前位置。我试图从Locationmanager method模拟器中获取位置,但在我的设备中(使用 wifi 的 Storm 2)我无法获得当前的纬度。

我的代码

    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();  
        }  
    }  

    public void providerStateChanged(LocationProvider provider, int newState) {  
        // no-op  
    }  
}
4

1 回答 1

1

我在寻找风暴问题的第一个地方发现了这个:If you run the above code on your BlackBerry device (for instance a Storm), you will get a "GPS not allowed" LocationProvider exception. You need to get your code signed if you want to use the BlackBerry Storm with GPS in your app. To do this, you need to buy a $20 certificate from RIM.

于 2011-09-26T13:25:39.757 回答