How to detect STAMINA mode?

匆匆过客 提交于 2020-01-12 07:00:08

问题


Can you help me, how to programmatically detect STAMINA mode on Sony devices?

I want to notify user that my app will not work properly if STAMINA is ON because it's blocking AlarmManager and device is not waked up when I want.


回答1:


I would like to know this too. I guess a naive way would be to check when the app was actually last awakened by AlarmManager and compare it to when you expected it to run. Keep track of shutdown and boot events to know if the phone was off.




回答2:


One way to handle this would be to check the device model and manufacturer on startup of your app and if its a sony device show your own dialog informing the user that they might experience issues.

See below for how to check the device details:

String deviceName = android.os.Build.MODEL;
String deviceMan = android.os.Build.MANUFACTURER;

if(deviceMan.equals("Sony") {
    showAlert();
}

Maybe you can check online which sony devices have this feature if not all do.



来源:https://stackoverflow.com/questions/19624377/how-to-detect-stamina-mode

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!