问题
Google introduced Doze and App Standby mode with Android 6.0 OS.
Device will enter in Doze
mode if device is unplugged and unused for some amount of time and if application stays inactive for some amount of time, that app goes in StandBy
mode (Correct me if I am wrong).
- Can we (developer) know, device entered in
Doze
mode or application entered inStandBy
mode? How?
http://developer.android.com/training/monitoring-device-state/doze-standby.html#whitelisting-cases In this link, Google says that Voip
or Chat
or Calling
application will still work when device is in Doze
mode.
- How OS will come to know that this is
Voip
orchat
orCalling
app, so i will keep it awake inDoze
mode too.?- What callback I need to register to complete maintenance task when application is out of
Doze
mode.?
回答1:
Yes, you can get informed of idle mode changes, by listening for DEVICE_IDLE_MODE_CHANGED intents, see: Android M listening to android.os.action.DEVICE_IDLE_MODE_CHANGED
You will need to whitelist your app, details here: https://developer.android.com/training/monitoring-device-state/doze-standby.html#support_for_other_use_cases
Same as for 1.
This page is also a really useful explanation of doze mode and how to test your app's handling of idle state: https://newcircle.com/s/post/1739/2015/06/12/diving-into-android-m-doze
来源:https://stackoverflow.com/questions/35811042/doze-and-app-standby-mode-in-android-6-0