Search code examples
androidrotationlandscape-portraitonconfigurationchanged

Set orientation programmatically but also listen for orientation changes?


Is it possible to set the orientation for an activity but to also listen for orientation changes using onConfigurationChanged()? In my activity, I want to start another activity when the user rotates the phone to landscape position, and to come back to that activity when the phone is rotated back to portrait. The only way I can listen for that is if I don't explicitly set to portrait or landscape using setRequestedOrientation() or android:orientation in the manifest.

If there is no way to set the orientation but also listens for rotation changes, how can I manually prevent the os from rotating my views on a configuration change?


Solution

  • I ended up scraping this idea and instead working with the android framework and having a landscape and portrait layout file. I don't think what I was trying to do is even possible.