4

For my android app, I want to keep the screen from dimming while certain activities (e.g. CatActivity) are in the resume state. Does anyone know how to do that? is there a way to declare so in the manifest or in the activity itself?

UPDATE

I found the answer:

  getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

Is there a way to turn it off? I don't see a removeFlags method.

learner
  • 11,490
  • 26
  • 97
  • 169

1 Answers1

2

To delete the flag simply call the clearFlags() method:

getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
Kuba Spatny
  • 26,618
  • 9
  • 40
  • 63