Stop App from Restarting when Screen is Rotated

One interesting problem I have encountered in Android development is that the when you rotate the device it restarts the activity from the start.  This is very annoying espeical to the end user who can get the splash screen again or have to start to from the begining of the app.

With a few simple lines of code you will be able to prevent this screen rotation from taking place.

Step 1:  Edit your android manifest.xml file to add in the following line to where the activity is displayed:


Step 2:  Add the following to your activity:

public void onConfigurationChanged(Configuration newConfig) {

This entry was posted in Android, Development and tagged , , . Bookmark the permalink.

Leave a Reply