I need to check whether the device is in power saving mode or not programmatically android.My application is run on 24/7.So in power saving mode ,network disabled and device goes to sleep.
Asked
Active
Viewed 6,553 times
2 Answers
9
Check this code.
PowerManager powerManager = (PowerManager)
getActivity().getSystemService(Context.POWER_SERVICE);
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP
&& powerManager.isPowerSaveMode())
{
}

Sagar Gangawane
- 1,985
- 1
- 12
- 22
2
Yes you can detect this by isPowerSaveMode () which returns boolean according to the mode of android device.
You can get more info here.

Surabhi Singh
- 803
- 8
- 14