Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Android recreate activities on Orientation Change

Tags:

android

Does anyone know the rationale behind the design of Android to destroy and re-create activities on a simple orientation change?

Shouldn't allowing the activity to just redraw itself (if it so chooses) be a better, simpler and more practical design?

BTW, I'm well aware of how to disable my app from orientation change effects, but what I don't really get is the reason for this design in Android

like image 931
source.rar Avatar asked Jul 30 '11 04:07

source.rar


People also ask

How do I stop Android from restarting activity when changing orientations?

If you want the activity to not restart during screen orientation change, you can use the below AndroidManifest. xml. Please note the activity android:configChanges=”orientation|screenSize” attribute. This attribute makes the activity not restart when change screen orientation.

How do you prevent 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 to activity when device is rotated?

On rotation of screen, The Activity is Destroyed. The Activity is Recreated fresh in requested orientation.


1 Answers

In docs, http://developer.android.com/guide/topics/resources/runtime-changes.html

it states that,

The restart behavior is designed to help your application adapt to new configurations by automatically reloading your application with alternative resources.

like image 74
sat Avatar answered Sep 28 '22 05:09

sat