Android的电源管理器WakeLock - 德precated管理器、电源、Android、WakeLock

2023-09-05 11:00:27 作者:细嫩长腿欧巴.

Android SDK中告诉我, PowerManager.SCREEN_DIM_WAKE_LOCK 和类似的常量pcated的API级别的德$ P $ 17。它还说, FLAG_KEEP_SCREEN_ON 在大多数情况下使用。

The Android SDK tells me that PowerManager.SCREEN_DIM_WAKE_LOCK and similar constants are deprecated as of API Level 17. It also says that FLAG_KEEP_SCREEN_ON can be used in most situations.

但是,如果这是不是这样的?我特别希望能够有灰色的屏幕,但不会关闭完全。什么是其他,更好的选择 - 或不存在简单的任何

But what if this is not the case? In particular, I want to be able to have the screen dimmed but not shut off entirely. What are other, "better" alternatives – or aren't there simply any?

推荐答案

目前还没有更好的替代品,以实际使用去precated WakeLock

There is currently no better alternative as to actually use the deprecated WakeLock.

其实你有另一种选择(但不是更好)。您可以使用 FLAG_KEEP_SCREEN_ON 与来自手动更改系统亮度的活动里面(的例如)。

Actually you have another alternative (but not better). You can use the FLAG_KEEP_SCREEN_ON in combination with changing the system brightness manually from inside your activity (example).

But what if this is not the case?

我有一个类似的情况中,我需要的屏幕为不断地对从服务(所以Activity.getWindow( )不可用)。在这种情况下,我使用pcated WakeLock直到Android的去$ P $来了一个新的API。

I'm having a similar situation in which I need the screen to be constantly on from a Service (so the Activity.getWindow() is not available). In this case i use the deprecated WakeLock until Android comes up with a new API.