My application uses gps location, but the request fails (time out error) every time if I stay inside of the building but location gets refresh well when I refresh the location from device Location Settings option if I stay in building too.
Here is my code
Criteria myCriteria = new Criteria();
myCriteria.setCostAllowed(false);
LocationProvider myLocationProvider = LocationProvider.getInstance(myCriteria);
Location myLocation = myLocationProvider.getLocation(((int)timeOutInMiliseconds/1000));
lastLatitude = myLocation.getQualifiedCoordinates().getLatitude();
lastLongitude = myLocation.getQualifiedCoordinates().getLongitude();
lastAltitude = myLocation.getQualifiedCoordinates().getAltitude();
lastAccuracy = myLocation.getQualifiedCoordinates().getHorizontalAccuracy();
lastSpeed = myLocation.getSpeed();
Please advise.
Ali
When you set the cost setting to false (
myCriteria.setCostAllowed(false);), you set the GPS mode to be autonomous (the below table was taken from Location based services development guide – Criteria mapping properties.Autonomous mode relies on GPS satellites only (see more about GPS modes here).
That’s the reason why your request fails. Try using other GPS modes: assisted or cellsite.
Assisted mode
For assisted mode use this snippet (it is worth noting that there are several assisted modes):
Cellsite mode
For cellsite mode use this snippet: