Android-Problems with locking the horizontal screen: android locks the horizontal screen
Android Developers should lock the horizontal screen as needed by the customer, and share the problems encountered during this period with you:
First, set in the project list file:Android: screenOrientation = "landscape" // lock the landscape
Android: configChanges = "keyboardHidden | orientation" // avoid repeated execution lifecycles
However, if the screen is still displayed in portrait mode, you need to add the code to mainActivity:
@ Override
Public void setRequestedOrientation (int requestedOrientation ){
Return;
}
@ Override
Public void onConfigurationChanged (Configuration newConfig ){
// TODO Auto-generated method stub
Super. onConfigurationChanged (newConfig );
}
I really thought this would be enough. When the mobile phone automatically locks the screen, he actually calls onDestroy (), which leads to re-executing the lifecycle during unlocking. Baidu knows:
The code in the project list file:
Android: configChanges = "keyboardHidden | orientation" changed:
Android: configChanges = "keyboardHidden | orientation | screenSize"
This is really done, and I hope to help you!