Meaning of Criteria.POWER_LOW for LocationManager

Viewed 193

The Criteria class is not documented in much detail.
Can someone please explain what POWER_HIGH and POWER_LOW change exactly?
Is it about battery drainage?

criteria.setPowerRequirement(Criteria.POWER_LOW);                
criteria.setAccuracy(Criteria.ACCURACY_FINE);
...
locationManager.requestSingleUpdate(criteria, locationListener, null);

Update: I went through some of the source code. It turns out this parameter is ignored in my example because an accuracy is set as well.

createFromDeprecatedCriteria() in LocationRequest.java:

    ...
    int quality;
    switch (criteria.getAccuracy()) {
        case Criteria.ACCURACY_COARSE:
            quality = ACCURACY_BLOCK;
            break;
        case Criteria.ACCURACY_FINE:
            quality = ACCURACY_FINE;
            break;
        default: {
            if (criteria.getPowerRequirement() == Criteria.POWER_HIGH) {
                quality = POWER_HIGH;
            } else {
                quality = POWER_LOW;
            }
        }
    }
    ...
1 Answers

There are a number of different LocationProviders (gps, network, passive etc). The Criteria class can be used by the LocationManger to automatically select the best provider based on your requirements.

Criteria criteria = new Criteria();
criteria.setPowerRequirement(Criteria.POWER_LOW);
criteria.setAccuracy(Criteria.ACCURACY_FINE);
criteria.setSpeedRequired(true);
criteria.setAltitudeRequired(false);
criteria.setBearingRequired(false);
criteria.setCostAllowed(false);

return locationManager.getBestProvider(criteria, true);

How the Criteria class is actually used can be seen here here. Setting the power requirement to Criteria.POWER_LOW would probably just rule out the device using the GPS location provider (since it uses far more battery than the other passive types).

Related