Respond to your own android: how to save state when rotating or orienting the screen

On a rotating screen, it seems that the activity is restarting, she is losing everything that she claims. I checked the Android developer guide. Handling runtime changes . It mentions how to handle the screen orientation and use onSaveInstanceState()it before it destroys your activity and restores state during onCreate()or onRestoreInstanceState().

+4
source share
2 answers

I answer my question how it worked for me if someone is facing the same problem and then edit your AndroidManifest.xml android / app / src / main and    local Kli / android-generator / templates / SRC / application / SRC / main

<activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
+2
source

Here is a detailed explanation of how to save / retrieve an activity instance in android http://www.intertech.com/Blog/saving-and-retrieving-android-instance-state-part-1/

+1
source

Source: https://habr.com/ru/post/1614920/


All Articles