How to check if Android Lollipop battery saver is on
Take a look at power manager
It has a method isPowerSaveMode()
that will tell you if battery saver is on
Example code:
PowerManager powerManager = (PowerManager) getActivity().getSystemService(Context.POWER_SERVICE);if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && powerManager.isPowerSaveMode()) { // Animations are disabled in power save mode, so just show a toast instead. Toast.makeText(mContext, getString(R.string.toast), Toast.LENGTH_SHORT).show();}
In Android lollipop Battery saver
has their own methods which tells you either Battery saver
is On
or Off
like isPowerSaveMode()
which returns a boolean
vlue.