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

发布于 2024-12-06 22:54:21 字数 1317 浏览 0 评论 0原文

如何在 Blackberry 应用程序中从 GPS 获取当前位置。我尝试从模拟器中的 Locationmanager 方法 获取位置,它工作正常,但在我的设备(使用 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  
    }  
}

How to get current location from GPS in Blackberry application. I tried to get location from Locationmanager method in simulator its work fine but in my device (Storm 2 using wifi) I am not able to get current lat long.

my code

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夜雨飘雪 2024-12-13 22:54:21

我在查找 Storm 问题的第一个地方就发现了这一点: 如果您在 BlackBerry 设备(例如 Storm)上运行上述代码,您将收到“GPS 不允许”LocationProvider 异常。如果您想在应用程序中使用带 GPS 功能的 BlackBerry Storm,则需要对代码进行签名。为此,您需要从 RIM 购买 20 美元的证书。

I found this on the first place I looked for storm issues : 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文