I need to keep my Activity’s layout in portrait mode but still get notified when the screen orientation changes in order to update my custom canvas. I have managed to prevent the Android OS from restarting my Activity and changing the layout when I change the screen orientation by putting these lines in my manifest XML:
android:screenOrientation="portrait"
android:configChanges="orientation"
I’m also aware that I can change the screen orientation programatically by calling the method setRequestedOrientation from the Activity.
The problem is that the method onConfigurationChanged doesn’t get called at all when I set the screenOrientation flag or call the method setRequestedOrientation. It does get called when I remove the flag from the manifest, but then the layout also gets updated which is not what I want.
Is there a way how to prevent the OS from changing the layouts but still be able to catch the configuration change?
Thanks!
I hope this class will solve your problem.