In my application I use only WebView for loading index.html where running all app logic(html's and javascript).
Where screen orientation changed, all data from JavaScript variables disappear.
How I can save all data when orientation changed?
In my application I use only WebView for loading index.html where running all app logic(html's and javascript).
Where screen orientation changed, all data from JavaScript variables disappear.
How I can save all data when orientation changed?
You have to catch orientation changes and handle them by yourself, because by default the Activity gets recreated (and your WebView will be reloaded).
Add the android:configChanges
attribute to your Activity in the AndroidManifest.xml
<activity ... android:configChanges="orientation|keyboardHidden|keyboard">
And override the onConfigurationChanged
method in your Activity class.
@Override
public void onConfigurationChanged(Configuration newConfig){
super.onConfigurationChanged(newConfig);
}
Also have a look here: Activity restart on rotation Android