0

I am writing app in android and I need to change time of screen activity. In settings I have 3 possible variants:

1) screen always active; 2) screen always active while charging; 3) normal screen activity (using default android user settings)

For first variant I found solution:

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

But if I understand right it works just for one Activity. How I can do it for all activities in my app? And what I should do for second and third variants? Can you help me with this? Thank you.

1 Answers1

0

A simple solution can be is to make a custom activity for that variant. After that u can extend all your other activities from the custom one. It will inherit everything from the upper class so also this part.

getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
Raber
  • 3
  • 1