V.J.
V.J.

Reputation: 9580

GPS Lat Lon Issue in Blackberry Storm

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.

My Code is .

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) {

    }
}

}

Upvotes: 1

Views: 898

Answers (2)

Himanshu Dudhat
Himanshu Dudhat

Reputation: 1609

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 :

http://appworld.blackberry.com/webstore/content/12255

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. ;)

Upvotes: 1

Govindarao Kondala
Govindarao Kondala

Reputation: 2862

Here No issue with code Gps is not supported 5.0 OS with LAN ,so I provide you some guides please verify.

Introduction to GPS and BlackBerry video.

The BlackBerry smartphone models and their corresponding GPS capabilities

How to detect whether my BB device has GPS support?

Some GPS Related Issues

Best practices for designing GPS applications for BlackBerry smartphones operating on CDMA networks

this is full information about blackberry GPS support

Upvotes: 1

Related Questions