Reputation: 1012
How can I know in my app if the phone is in Doze mode or if my app is in Standby mode?
Can I also know it by using some subscribing approach?
Upvotes: 16
Views: 5608
Reputation: 3460
There's a difference between App Standby (where your app goes to sleep because it's lonely) and Doze (where the system went to sleep because users have lives).
Doze only works when your device remains stationary. If you pick it up or wake the screen, Doze mode is deactivated and the timer resets. It won’t ever turn on when the phone is sitting in your pocket unless you’re sitting remarkably still. Doze simply keeps your phone from burning through the battery while it’s asleep on a desk or table or something.
An app that goes into Standby loses all network access and all its background sync jobs are suspended. These restrictions are temporarily lifted when your phone is plugged in and for a few minutes every day or two. This gives suspended apps a chance to run any pending sync jobs, but they won’t be allowed to continue running. A high-priority push notification will also be able to wake an app from Standby for a short time.
Note: Google has also noted that it isn’t acceptable for apps to fire off notifications simply to remain exempt from App Standby. This sort of behavior can get an app banned from the Play Store.
For more details with testing Doze and App Standby, Please visit this link: https://developer.android.com/training/monitoring-device-state/doze-standby.html
Thanks!
Upvotes: 4
Reputation: 2691
You don't need to do anything to manage Standby mode. You just need to manage you lifecycle as usual. There will be a time in the day when you app is gonna be resumed (so you can sync data and resume delayed jobs), but notifications and alarms will always bring your app out of standby.
Check this out: https://plus.google.com/+AndroidDevelopers/posts/76eh5MaJaXj?linkId=18331776
Upvotes: 0