Lollipop isPowerSaveMode always returns false

六月ゝ 毕业季﹏ 提交于 2019-12-13 15:44:17

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!