20

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?

Ingo Bürk
  • 19,263
  • 6
  • 66
  • 100
  • 14
    I must say, android devs loves deprecating the stuff all over the sdk. They might have some random deprecation generator who tell them on each release which ones to mess with. – xmen Jun 25 '13 at 11:44

1 Answers1

17

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.

Suraj Rao
  • 29,388
  • 11
  • 94
  • 103
Twinone
  • 2,949
  • 4
  • 28
  • 39