简体   繁体   English

Webview行为唤醒Android

[英]Webview behaviour wakelock android

How WebView works with wake lock? WebView如何与唤醒锁一起工作?

Flag Value               CPU   Screen   Keyboard
PARTIAL_WAKE_LOCK        On*    Off      Off
SCREEN_DIM_WAKE_LOCK     On     Dim      Off
SCREEN_BRIGHT_WAKE_LOCK  On    Bright    Off
FULL_WAKE_LOCK           On    Bright   Bright

*If you hold a partial wake lock, the CPU will continue to run, regardless of any display timeouts or the state of the screen and even after the user presses the power button. *如果您拥有部分唤醒锁,则无论任何显示超时或屏幕状态,甚至在用户按下电源按钮之后,CPU都将继续运行。 In all other wake locks, the CPU will run, but the user can still put the device to sleep using the power button. 在所有其他唤醒锁中,CPU将运行,但用户仍可以使用电源按钮将设备置于睡眠状态。

In addition, you can add two more flags, which affect behavior of the screen only. 此外,您还可以添加两个标志,它们仅影响屏幕的行为。 These flags have no effect when combined with a PARTIAL_WAKE_LOCK . 当与PARTIAL_WAKE_LOCK结合使用时,这些标志无效

This two FLAGS: 这两个标志:

ACQUIRE_CAUSES_WAKEUP Normal wake locks don't actually turn on the illumination. ACQUIRE_CAUSES_WAKEUP正常的唤醒锁实际上不会打开照明。 Instead, they cause the illumination to remain on once it turns on (eg from user activity). 取而代之的是,一旦照明打开(例如,来自用户活动),它们就会使照明保持打开状态。 This flag will force the screen and/or keyboard to turn on immediately, when the WakeLock is acquired. 当获取WakeLock时,此标志将强制屏幕和/或键盘立即打开。 A typical use would be for notifications which are important for the user to see immediately. 典型的用途是用于通知,这对于用户立即查看很重要。

ON_AFTER_RELEASE If this flag is set, the user activity timer will be reset when the WakeLock is released, causing the illumination to remain on a bit longer. ON_AFTER_RELEASE如果设置了此标志,则释放WakeLock时将重置用户活动计时器,从而使照明保持更长的时间。 This can be used to reduce flicker if you are cycling between wake lock conditions. 如果您在唤醒锁定条件之间循环,这可用于减少闪烁。

Scenario: App running one webview that need wait for onPageFinished() to do the processing (And yes, I need to use wake lock, this is just the simplest scenario) 方案:运行一个Web视图的应用程序需要等待onPageFinished()进行处理(是的,我需要使用唤醒锁,这只是最简单的方案)

WebView本身不会获取唤醒锁,这完全取决于应用程序的代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM