I have tried the following code:
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
However, it only works when the program is on screen.
My app will launch Chrome to visit a website and it becomes background. At this time, it doesn't work.
If I want to keep the screen on when I launch my app, even though it may be at background, how can I do to implement it?