2

I have a foreground notification service that continuously monitors user's actions, using ActivityRecognition, and writes them to AWS anytime user's state changes. It works good for some time. However I noticed when user is idle for longer time, such as user is sleeping overnight, then the app (activity and service) silently dies. I assume this is because of doze mode (because I whitelisted the same app on a different phone and it is working fine for over 2 days now)

How to WhiteList app in Doze mode Android 6.0 gives good overview on how to disable doze mode with user intervention. But @commonsware blog below suggests about Google 'possibly' banning the apps that show the corresponding popup box https://commonsware.com/blog/2015/11/11/google-anti-trust-issues.html

 Note: Google Play policies prohibit apps from requesting direct exemption from Power Management features in Android 6.0+ (Doze and App Standby) unless the core function of the app is adversely affected.

Can someone help me in understanding what features can possibly comprise "core functions", so Google would not ban my app. We know doze mode doesn't affect some apps like WhatsApp

EDIT

I see this on Samsung phones with 6.0.1

Community
  • 1
  • 1
mobileDev
  • 1,358
  • 2
  • 14
  • 34
  • https://developer.android.com/training/monitoring-device-state/doze-standby.html#whitelisting-cases is the only documentation that I know of on the subject. – CommonsWare Jan 28 '17 at 21:33

1 Answers1

2

Android does not kill services in the background with Doze. Per the ActivityRecognitionApi documentation:

To conserve battery, activity reporting may stop when the device is 'STILL' for an extended period of time. It will resume once the device moves again. This only happens on devices that support the Sensor.TYPE_SIGNIFICANT_MOTION hardware.

Therefore it is entirely expected to have a significant period of time where you won't get any activity recognition callbacks. In those cases, you can assume that the last received activity (STILL) is still applicable.

ianhanniballake
  • 191,609
  • 30
  • 470
  • 443
  • I dont see activity/service in task manager, notification bar at the top disappeared, periodic timer that has log statements no longer spits them out - altogether makes me believe doze mode is killing my app. – mobileDev Jan 28 '17 at 21:49
  • 2
    The [doze restrictions](https://developer.android.com/training/monitoring-device-state/doze-standby.html#restrictions) does not include killing your service. Perhaps that device manufacturer does something different though? Are you testing on a Nexus device? – ianhanniballake Jan 28 '17 at 21:51
  • this is happens on Samsung and not on Moto (haven't tried on other phones) – mobileDev Jan 28 '17 at 22:06