Android KitKat 4.4中有省电模式。它将优化GPS和其他功能,以节省电池寿命。是否可以检查手机是否处于省电模式?
答案 0 :(得分:1)
以下应该有所帮助,请注意,这仅适用于API级别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");
}
}