I´ve had some trouble as well in the past, but I've managed to overcome any problems. Try this:
Code:
Criteria c = new Criteria();
// We're aiming for Assisted and/or Autonomous GPS
c.setAddressInfoRequired(false);
c.setCostAllowed(true); // this means 'allow assisted GPS', as the network will be used
c.setSpeedAndCourseRequired(true); // overriden from default
c.setHorizontalAccuracy(Criteria.NO_REQUIREMENT);
c.setPreferredPowerConsumption(Criteria.POWER_USAGE_HIGH); // This signifies Ass. GPS and Aut. GPS
c.setVerticalAccuracy(Criteria.NO_REQUIREMENT);
try
{
_instance._locationProvider = LocationProvider.getInstance(c);
if ( _instance._locationProvider == null )
{
_gpsPositionlistener.GPSPositionNotFound(GPSPositionListener.ERROR_NO_GPS_DEVICE_AVAILABLE);
return;
}
// we want fixes every 3 seconds, when the GPS is on
// for every fix during those 3 seconds, we filter the invalid locations (i.e.,
// those that do not qualify as full-fledged GPS locations)
// we don't use timeout, or maxage, as we determine for ourselves what locations
// we want to use
_instance._locationProvider.setLocationListener(_instance, 3, -1, -1);
}
catch (LocationException ex){}
catch (SecurityException ex){}
catch (IllegalArgumentException e){}