During Android development, some programs do not need to automatically lock the screen when running, that is, keep the background light of the system on normally, to prevent exceptions during program execution, you only need to add the following statement to the oncreate () method when creating an activity.
Getwindow (). addflags (windowmanager. layoutparams. flag_keep_screen_on );
In addition, if the screen is flipped during the program running, the android system automatically changes the screen direction. At this time, the system will re-call the oncreate () method to create the activity, therefore, during program development, you must pay attention to saving the scene and switching the screen width to width ratio. If you do not need this function, you can go to androidmanifest. modify the XML file by adding the following statement to each activity.
Android: screenorientation = "portrait" // portrait indicates that the screen is vertical.
Eg:
<Activity Android: Name = "mainactivity"
Android: Label = "@ string/hello"
Android: screenorientation = "portrait">
</Activity>