How to programmatically detect SONY - Stamina devi

2019-04-06 09:25发布

问题:

I want to notify user that my app will not work properly if he has SONY android phone with STAMINE energy profile ON. This profile is blocking AlarmManager and device is not waked up when I want.

回答1:

Currently, there is no official way to detect if the STAMINA energy profile is selected. However, if there is enough community demand we may be able to open this up.



回答2:

You could check it via

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

Works at least on the Sony Xperia XZ1 Compact (8.0.0)