保持清醒的屏幕可以实现通过使用wakelock通过
Keeping the screen awake can be accomplished by using a wakelock by
mWakeLock = mPowerManager.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, getClass().getName());
或者通过将FLAG_KEEP_SCREEN_ON到窗口,
Or by adding the FLAG_KEEP_SCREEN_ON to the window,
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
这是在两者之间并在性能和电池寿命方面,这是推荐的技术差异?
What is the technical difference between the two and in terms of performance and battery life which is recommended?
推荐答案一个wakelock给你的方式更多的控制(像唤醒手机下载的东西,而不转动屏幕关闭),并要求您的应用程序保持wakelock权限。
A wakelock gives you way more control (Like waking the phone to download something without turning the screen off) and requires your application to hold the wakelock permission.
因此 FLAG_KEEP_SCREEN_ON 建议如果你想要的是保持在屏幕上,而你的窗口是可见的。
Therefore FLAG_KEEP_SCREEN_ON is recommended if all you want is to keep the screen on while your window is visible.
更多推荐
Wakelock和FLAG
发布评论