user1002448
user1002448

Reputation: 415

Checking battery saving mode in kitkat 4.4

There is a battery saving mode in Android KitKat 4.4. It will optimize the GPS and other features to save battery life. Is it possible to check whether ones phone is in battery saving mode ?

Upvotes: 1

Views: 1857

Answers (1)

ozbek
ozbek

Reputation: 21183

Following should help, please note that this is available only on API level 19+:

private void checkLocationModeSettings() {
    int mode = Settings.Secure.getInt(getContentResolver(), Settings.Secure.LOCATION_MODE,
            Settings.Secure.LOCATION_MODE_OFF);

    switch (mode) {
        case Settings.Secure.LOCATION_MODE_SENSORS_ONLY:
            Log.d(TAG, "Sensor only mode");
            break;
        case Settings.Secure.LOCATION_MODE_BATTERY_SAVING:
            Log.d(TAG, "Battery saving mode");
            break;
        case Settings.Secure.LOCATION_MODE_HIGH_ACCURACY:
            Log.d(TAG, "High accuracy mode");
            break;
        case Settings.Secure.LOCATION_MODE_OFF:
        default:
            Log.d(TAG, "Location access is disabled");
    }
}

Upvotes: 1

Related Questions