--ADVERTISEMENT--

In this simple tip, I am going to show how to stop activity restart when rotating/changing orientation in android device and emulator. By default in android while rotating the screen, the activity gets automatically restarted. So, following example shows you how to prevent/solved it.

Related:
How to Make Android TextView Text Selectable
How to Use Font Awesome Icons in Android Application
How to Increase the Integer Value When Screen is Touched

To stop restarting android activity you have to add a line in AndroidManifest.xml file of android project.
android:configChanges="keyboardHidden|orientation"

Android Example: How to Stop Activity Restart on Rotation


XML Layout File

res/layout/stop_restart_activity_when_rotate.xml

Java Activity File

src/StopRestartActivityWhenRotate.java

AndroidManifest.xml File

src/main/AndroidMainfest.xml

Android Example: How to Stop Activity Restart on Rotation

Now, run your Stop Activity Restart on Rotation application and type any word in edit box and rotate your device screen.

Post a Comment

Powered by Blogger.