问题
I am trying to know if the PowerSaveMode is activated or not. I am using this code:
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
return pm.isPowerSaveMode();
But it always returns FALSE. I have only tried with a Samsung Galaxy S4 with 5.0.1 because is the only Lollipop device I have around. Any tips?
回答1:
I found out that Samsung works in a different way. Like always Android loves to be tricky.
bActivated = Settings.System.getString(context.getContentResolver(), "psm_switch").equals("1");
I also read that for HTC has to be this way:
bActivated = Settings.System.getString(context.getContentResolver(), "user_powersaver_enable").equals("1");
来源:https://stackoverflow.com/questions/35634961/lollipop-ispowersavemode-always-returns-false