How Do I Stop Android from Restarting Activity When Changing Orientations?
Contents

If you want the activity do not restart during screen orientation change, you can use below AndroidManifest. xml. Please note the activity android_configChanges=”orientation|screenSize” attribute. This attribute make the activity not restart when change screen orientation.

How do you prevent the data from reloading and resetting when the screen is rotated?

Just add android_configChanges=”orientation|screenSize” in activity tab of manifest file. So, Activity won’t restart when orientation change.

What happens when screen orientation changes in Android?

If orientation changes is not handle properly then it results unexpected behavior of the application. When such changes occurs, Android restarts the running Activity means it destroy and again created.

Sarah Jenkins

Sarah Jenkins

Senior Technology Editor & AI Specialist

Sarah Jenkins is a veteran tech journalist with over 12 years of experience covering artificial intelligence, mobile innovations, and digital ethics. Her insights have appeared in leading technology publications worldwide.

Share this article
Twitter Facebook Pinterest