This application works perfect in the simulator. It also works if the device is put outside the building.
But not working inside the building.
I found that BlackBerryCriteria() constructor sets the GPS mode in the following order: Autonomous, Assisted, Cellsite mode.
But in my case only Autonomous is working. If Autonomous is not available, I need to switch to Assisted or Cellsite mode.
My understanding on GPSInfo.isGPSModeAvailable() is, it only checks whether the mode is supported on blackberry device, right?
I need someone's help to solve this problem.
Here's my code snippets
Code:
public void setNewLocation() {
Thread t = new Thread(new Runnable() {
public void run() {
try {
BlackBerryCriteria criteria = new BlackBerryCriteria();
criteria.setCostAllowed(true);
criteria.setPreferredPowerConsumption(BlackBerryCriteria.POWER_USAGE_MEDIUM);
criteria.setHorizontalAccuracy(BlackBerryCriteria.NO_REQUIREMENT);
criteria.setVerticalAccuracy(BlackBerryCriteria.NO_REQUIREMENT);
criteria.setGPSRestartInterval(120, 3);
BlackBerryLocationProvider locProvider = (BlackBerryLocationProvider) LocationProvider.getInstance(criteria);
if(locProvider!=null){
locProvider.setLocationListener(new MyLocationListener(),
30, 15, 15);
}
} catch (Exception e) {
addErrorQueue(e.getMessage());
}
}
});
t.start();
}
And the listener code is
Code:
public class MyLocationListener implements LocationListener {
public void locationUpdated(LocationProvider provider, Location myLocation) {
if (myLocation instanceof BlackBerryLocation) {
if (myLocation.isValid()) {
BlackBerryLocation location = (BlackBerryLocation) myLocation;
try {
QualifiedCoordinates qc = location.getQualifiedCoordinates();
double lat = qc.getLatitude();
double lon = qc.getLongitude();
float heading = location.getCourse();
float speed = location.getSpeed();
int satellites = location.getSatelliteCount();
addLocationQueue(new MyLocation(........));
} catch (Exception ex) {
addErrorQueue(ex.getMessage());
}
}
else
{
addErrorQueue("Invalid location");
}
}
}
public void providerStateChanged(LocationProvider provider, int newState) {
}
}