Android save state on orientation change

Add android:configChanges in the Manifest file

<activity name= ".MainActivity" 
 android:configChanges="orientation|screenSize"/>

By default, this does not work because changing the orientation causes the onCreate method to be called again and redraws the view.

However, if this parameter is included, the framework will handle preserving the state of the screen or layout if the orientation is changed.

Refer following official documentation for more info:

Activity Lifecycle

Handling configuration changes

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)