Keep the screen normally on android, while the android screen always on
Many articles on the Internet on the issue of keeping the screen always bright during android development indicate the need to work with PowerManager and WakeLock, and set the FLAG to FULL_WAKE_LOCK, SCREEN_BRIGHT_WAKE_LOCK, or SCREEN_DIM_WAKE_LOCK.
However, you can check the source code of the PowerManager class to find that these FLAGs have been discarded. That is to say, PowerManager does not need to control whether the screen is always bright. This is the same as the previous BRIGHTNESS_DIM deletion.
When you need a layout to always light up the screen, add the FLAG FLAG_KEEP_SCREEN_ON to layoutParams and remove the FLAG when the flat is canceled. Note that you need to call the WindowManager updateViewLayout () method after the change.
For more information about WindowManager and LayoutParams, see this document.
We are about to leave for Shanghai tomorrow to have fun with our classmates :)