Younes Ben Tlili
Younes Ben Tlili

Reputation: 312

How detect PowerSaveMode change in Android

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 ?

Upvotes: 1

Views: 341

Answers (1)

Nensi Kardani
Nensi Kardani

Reputation: 2366

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);

Upvotes: 2

Related Questions