本文介绍了在黑莓风暴GPS纬度经度问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写我的应用程序下面的code。
它会在模拟器运行成功,但同时我为试图在我的设备运行,那么它给纬度和放大器;经度(0.0,0.0)。
这是什么问题。

I Write the following code in my application.It will run successfully in Simulator but while i m trying to run in my device then it gives Lat & Lon (0.0,0.0).What is the problem.

我的code为。

public class GetLatLon extends TimerTask{
public static Timer timer;
private double longitude;
private double latitude;

public GetLatLon(int duration) {
    timer = new Timer();
    try {
        // TODO: update criteria with desired location distances, etc
        LocationProvider.getInstance(new Criteria()).setLocationListener(
                new MyLocationListener(), 1, 1, 1);
    } catch (Exception e) {
        System.err.println(e.toString());
    }

    timer.schedule(this, 0, 10000);
}

public void run() {
    System.out.println("Lattitude :-"+ latitude);
    System.out.println("Longitude :-"+ longitude);
}

public double getLongitude() {
    return longitude;
}

public void setLongitude(double longitude) {
    this.longitude = longitude;
}

public double getLatitude() {
    return latitude;
}

public void setLatitude(double latitude) {
    this.latitude = latitude;
}

private class MyLocationListener implements LocationListener {
public void locationUpdated(LocationProvider provider, Location location) {
    if (location != null && location.isValid()) {
        QualifiedCoordinates qc = location.getQualifiedCoordinates()
                     try {
        GetLatLon.this.longitude = qc.getLongitude();
        GetLatLon.this.latitude = qc.getLatitude();
        } catch (Exception e) {
             System.err.println("criccomini " + e.toString());
        }
        } else {
            System.err.println("criccomini location not valid");
        }
    }

    public void providerStateChanged(LocationProvider provider, int newState) {

    }
}

}

推荐答案

我也遇到同样的问题,9550风暴2。
我想,你所面临的问题,由于设备的GPS值不正常启动。尝试使用这个工具:

I had also faced same problem with 9550 Storm-2.I think you face the problem due to your device GPS value does not initiate properly. Try to use this tool :

这将引发GPS值(PLZ不要关闭这个工具只是$ P $发送到后台pssing红色键)。之后启动GPS值尝试运行应用程序,你

this will initiate the GPS values(Plz don't close this tool just send it to background by pressing red key).After initiate the GPS value try to run you application.

我希望问题会得到解决。 ;)

i hope problem will be solved. ;)

这篇关于在黑莓风暴GPS纬度经度问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 04:09