据当系统处于休眠模式的Android棉花糖文档,任何wakelock被忽略。但是这不是我清楚,如果wakelock prevent打盹模式或不。
According to Android Marshmallow documentation when the system is in doze mode, any wakelock is ignored. However it's not clear to me if a wakelock prevent doze mode or not.
推荐答案根据一些测试,使用的Nexus 5的最后$ P $的Android 6.0的PVIEW安装(?):
Based on some testing, using a Nexus 5 with the the final(?) preview of Android 6.0 installed:
-
拿着 PARTIAL_WAKE_LOCK 不足以阻止打盹模式—该设备仍然会打瞌睡,即使你有 WakeLock 和正在尝试做的日常工作(例如, setExactAndAllowWhileIdle()得到控制每分钟)
Holding a PARTIAL_WAKE_LOCK is insufficient to block Doze mode — the device will still doze, even though you have the WakeLock and are trying to do regular work (e.g., setExactAndAllowWhileIdle() to get control every minute)
保持在屏幕上使用安卓keepScreenOn (或相当于Java),在屏幕上,是的足够块打盹模式
Keeping the screen on using android:keepScreenOn (or the Java equivalent), with the screen on, is sufficient to block Doze mode
保持在屏幕上使用安卓keepScreenOn (或相当于Java),与屏幕关闭(用户presses POWER键),是不够的阻止打盹模式
Keeping the screen on using android:keepScreenOn (or the Java equivalent), with the screen off (user presses POWER button), is insufficient to block Doze mode
IOW,视频播放器等,不应当用户正在观看的视频,即使玩家可能不被移动或充电受到影响。但是,如果用户presses POWER键,你回有打盹的危险。
IOW, video players and the like should not be affected while the user is watching the video, even though the player may not be moving or charging. However, if the user presses the POWER button, you're back into having Doze risk.
我没有使用 FULL_WAKE_LOCK (我期望的行为等同于 Android的尝试:keepScreenOn ,但我很远某些)。
I have not tried using FULL_WAKE_LOCK (I would expect behavior identical to android:keepScreenOn, but I am far from certain).
更多推荐
Wakelock和打盹模式
发布评论