How detect PowerSaveMode change in Android

300 Views Asked by At

I'm trying to detect the PowerSaveMode change for battery. I'm using the method pm.isPowerSaveMode(). The problem that i have always a false result. I'm trying to update the statut to enable but always the result is false. I'm using three differents devices, S8+ (Android 9) , One plus(Android 10), Sony (Android 10)...

Any solution please ?

1

There are 1 best solutions below

0
Nensi Kasundra On

This is working fine in OnePlus(Android 10) and emulator(Android 10)

 PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
 boolean powerSaveMode = powerManager.isPowerSaveMode();
 Log.e("Power Saver", "Mode is " + powerSaveMode);