Android: Loss of GPS signal strength on some phones when I launch the Camera and SurfaceView

advertisements

I am working on an app that takes GPS encoded pictures.

I am able to get about 15 - 20 meters accuracy GPS signal strength when I am not running the camera, and have at least 3 satellites in range, sometimes 5 - 7 satellites.

However, when I start up an activity that both displays the SurfaceView with the Camera hooked up to it AND the GPS code, my accuracy goes way down (> 100 meters), but only on some phones.

Phones that it does not work on:

  1. Droid Incredible 2
  2. HTC Wildfire
  3. HTC Inspire

Phones that it does work on:

  1. Atrix
  2. Galaxy Tab
  3. Motorolla Droid (The original)

So, my questions are, why would this happen? And of course, how can I fix it?

Here is my code that I am using to stoke up the GPS

try{
    locator = new GeoLocator(this);
    locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    locationManager.addGpsStatusListener(new GPSStatusManager(locationManager));
    Criteria criteria = new Criteria();
    criteria.setAccuracy(Criteria.ACCURACY_FINE);
    criteria.setPowerRequirement(Criteria.NO_REQUIREMENT);
    bestProvider = locationManager.getBestProvider(criteria, true);
    Bundle bundle = new Bundle();
    //I copied the next two lines out of some tutorial hoping that they would help boost my gps, but I'm really not sure what they do
    boolean xtraInjection=locationManager.sendExtraCommand(LocationManager.GPS_PROVIDER,
                                          "force_xtra_injection",bundle);
    boolean timeInjection=locationManager.sendExtraCommand(LocationManager.GPS_PROVIDER,
                                          "force_time_injection",bundle);
    locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 0.0f, locator);
}catch(Exception e){}


Complete guess here, but try changing this line:

criteria.setPowerRequirement(Criteria.NO_REQUIREMENT);

to this:

criteria.setPowerRequirement(Criteria.POWER_HIGH);

Theory: by not specifying high power requirement for the GPS, you're allowing the OS to run the GPS in a less-power-consumptive mode, which it does whenever you turn on other power-consuming accessories. When the GPS is run in low-power mode, that will make it less accurate.