keep android screen from dimming while activity is running

Viewed 895

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.

1 Answers
Related