Android PowerManager WakeLock – Deprecated

后端 未结 1 713
一向
一向 2021-02-12 13:10

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

相关标签:
1条回答
  • 2021-02-12 13:25

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

    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?

    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.

    0 讨论(0)
提交回复
热议问题