0

I'm using getWindow().addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON); to turn on the screen programmatically. Is there a WindowManager feature that turns off the screen progrmamatically? I want the user to press a button and then exit out of the activity and turn off the screen.

rainingdx
  • 27
  • 6

1 Answers1

0

As far as i know, you cant really turn the screen off (in the traditional sense). You can, however, dim it as much as possible (like the Phone app does for instance, when you move your phone close to your face).

Check THIS answer for the solution. Just modify the code so it doesn't use the onSensorChanged listener.

Community
  • 1
  • 1
Squeazer
  • 1,234
  • 1
  • 14
  • 33