Whilst detecting power saving mode (at least on Lollipop+) is very easy, some manufacturers implement their own battery saving systems. One of the least standards-conforming of these is Sony’s Stamina Mode. Luckily this is easily detected, albeit in an unofficial way.

It’s important to note that this method only detects if the mode is enabled in general, not whether it is currently in use. For example, if a user has the mode set to activate on <15% battery, this method will return true even if the battery is currently 100%. Regardless, since the only official response is “there is no official way” from 5 years ago, this is the best available for now!

First, check the device is a Sony device. If it’s not, stamina mode definitely won’t be on!

if (Build.MANUFACTURER.toUpperCase() == "SONY") {

Next, check if the somc.stamina_mode settings value is set to 1. This is done by using android.provider.Settings, you may need to replace contentResolver with context.getContentResolver():

Settings.Secure.getInt(contentResolver, "somc.stamina_mode", 0) == 1

For example, a Kotlin function to display a bar if Sony’s Stamina Mode is on may look like:

private fun performSonyPowerSavingCheck() {
    if (Build.MANUFACTURER.toUpperCase() == "SONY") {
        togglePowerSavingBar(
            Settings.Secure.getInt(contentResolver, "somc.stamina_mode", 0) == 1
        )
    }
}