在Blackberry应用程序中从GPS获取当前位置

时间:2011-09-26 12:17:07

标签: blackberry gps blackberry-storm locationmanager

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

我的代码

    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  
    }  
}

1 个答案:

答案 0 :(得分: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.