I have an android application that I want to always be running in landscape mode.
I have the following code implemented to keep the app in landscape mode all the time:
inside my activity in the Application Manifest
android:screenOrientation="landscape"This seems to launch and keep the application in landscape view for the whole duration of the application. Perfect!
However, if I have the app running on my HTC Aria (Android 2.1) and the phone locks, if I unlock the phone, I see the application for probably half a second and it's in portrait orientation and then quickly switches back to landscape mode. It is quite frustrating because all of my views are jumbled around and it looks unprofessional as you can开发者_开发百科 imagine. This happens in both the emulator and on my real phone.
Does anyone know how to stop the application from temporarily rotating when the phone is unlocked?
Additions:
I have tried overriding onConfigurationChanged() but with no success.I have also tried putting setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); into the onResume() but the app still shows as the incorrect orientation for a split second when the phone is unlocked.
Try setting the orientation in the manifest file. it might just work.
After looking at many other apps that are made for landscape orientation only, I can see that their apps don't freeze their orientation after standby either. I have a feeling that this is a limitation of the phone, and that all apps will switch to a portrait orientation when the phone is locked. If all apps have this "problem" then I think it is acceptable not to fix.
Please post if you have found out there is a way to stop the forced portrait orientation.
the app still shows as the incorrect orientation for a split second when the phone is unlocked.
Did you move setContentView(R.layout.main)
to the onResume
, AFTER where you put your orientation code? I would try setting the orientation, then the setContentView()
精彩评论