Skip to content Skip to sidebar Skip to footer

How Save Webview When Screen Orientation Was 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

Solution 1:

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.

@OverridepublicvoidonConfigurationChanged(Configuration newConfig){
    super.onConfigurationChanged(newConfig);
}

Also have a look here: Activity restart on rotation Android

Post a Comment for "How Save Webview When Screen Orientation Was Changed"