In My Manifest.xml file, if I have the following ‘android:configChanges’ for MyActivity, it does not pick up my layout file in res/layout-land when I rotate my phone to landscape mode.
<activity
android:name="MyActivity"
android:configChanges="orientation|keyboard|keyboardHidden">
</activity>
Can you please tell me how can I fix it?
Thank you.
By including orientation in configChanges, you’re disabling the default layout-change behaviour, which is to re-start your activity in the new orientation.
You’ll need to manually change the layout used when you get CONFIGURATION_LANDSCAPE/CONFIGURATION_PORTRAIT in onConfigurationChanged.
Note that according to the Activity docs, onConfigurationChanged is a ‘last resort’ option – it’s generally better to persist state and let the system re-launch your app.
Best wishes,
Phil Lello