When developing Android programs, sometimes the system cannot be hibernated when the program is running, otherwise some operations will stop. Therefore, we need to set hibernation prohibition, there are two ways:
One is to add permissions.
One is the setting in the code,
It is recommended to use the first method, so that you will be reminded when installing the program:
The first method:
Use user-permission declaration in the file
Name is:.WAKE_LOCK
The second method:
getWindow().setFlags(.FLAG_KEEP_SCREEN_ON, .FLAG_KEEP_SCREEN_ON);
Add this code tosetContentView()Just before.
The above content is the method of setting up the Android system to never lock the screen and never sleep. I hope it will be helpful to everyone.