I am writing an Android application that will run on phones and Honeycomb tablets, and pretty much runs different activities based on the OS and right from the get-go. On non-honeycomb devices, I have all of my activities locked to portrait for ease of UI, and the same thing goes for honeycomb, only they’re all locked to landscape, again for better UI and user experience.
I have some dialog-themed activities, such as a file browser that I wrote, that I’d like to use on either device, and have the dialog activity be the same orientation as the current application. So if the user is using a phone, the dialog would show up in portrait, they could select their file, and the activity would disappear and the user would continue. If they are using a Honeycomb device, the dialog activity would appear in landscape and the same rules would apply.
I don’t want to allow the orientation to change dynamically, however. If the file browser activity is on screen, the user should not be allowed to rotate the device, because the underlying activities don’t support it.
I’m looking for suggestions on how to accomplish this.
You can add
android:configChanges="orientation"on the activity in the AndroidManifest to inform the OS that you are handling orientation changes. Usually we would implement some kind of handling in theonConfigurationChangedmethod, but in this case you are doing nothing.