12

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.

Kikju
  • 787
  • 1
  • 6
  • 17
  • I do not believe that there is a way to detect STAMINA mode. – CommonsWare Oct 28 '13 at 00:07
  • Well, for example... app Timely is showing dialog, when STAMINA is on (when starting app). So, there must be a way... – Kikju Oct 28 '13 at 15:02
  • @Kikju Which Timely app are you talking about? I can find several on Google Play. – hajons Mar 12 '14 at 12:53
  • Maybe check if there's a system property for it? – Buddy Jul 10 '15 at 03:24
  • see if http://stackoverflow.com/questions/25018132/detecting-android-l-battery-saver can help – Tiger Meng Dec 16 '15 at 06:50
  • @Kikju could you please tell us which Timely app are you talking about as hajons asked? I'd like to contact the creators and ask them how they did it. Thanks! – David Riha Mar 16 '16 at 19:26
  • @DavidŘíha I meant this app: https://play.google.com/store/apps/details?id=ch.bitspin.timely I also contacted them and they said me, that they just show dialog for all types of phones at first start of app. – Kikju Mar 20 '16 at 18:49

2 Answers2

0

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.

hajons
  • 135
  • 4
0

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.

FrankR
  • 196
  • 10