Hi,
I'm writing an application that needs to use GPS position, and I wrapped the logic about the GPS in a class that I call LocationManager.
When I activate the LocationManager I register with the LocationProvider, with a very small timeout.
I find that, on some devices (some 8310 and 8130), the location provider does not return a valid location until the GPS is used by another application (e.g. refreshing the location through Options->Advanced Options->GPS, or BB Maps).
Following is the code where I'm activating the LocationManager. Am I missing something?
Code:
private final static int LOCATION_UPDATE_INTERVAL = 1;
...
public void activateLocationManager() {
try {
locationProvider = LocationProvider.getInstance(new Criteria());
if (locationProvider != null) {
resetGpsDevice();
} catch (LocationException e) {
MyApplicationClass.log("Could not get location provider", EventLogger.ERROR);
}
}
public void resetGpsDevice() {
if (locationProvider != null) {
locationProvider.setLocationListener(null, 0, 0, 0);
locationProvider.reset();
locationProvider.setLocationListener(this,
LOCATION_UPDATE_INTERVAL, 1, 1);
}
}
Thanks,
Oliver