Android Webview content should not be lost when changing orientation, but the GUI must be updated correctly

I am trying to save loaded page values ​​and javascript WebView when changing orientation and pausing. At first I tried to override configChanges, but this led to my GUI not updating properly (I have a sliding frame that changes position when changing orientation). After that, I tried to put the WebView in the fragment and call setRetainInstance (true); But this does not prevent the retention of WebView content. I tried to save the same object without recreating it, but android does not allow reusing views.

my question is: is there a way to save the contents of the web view without having to reload it every time the orientation changes, while the other components of the GUI will be updated correctly.

I hope my question is clear enough, but I would be happy to work out if there are any strange things.

EDIT: I already tried adding android: configChanges = "keyboardHidden | orientation" in my manifest, this is what I meant by "overriding configurations"

It seems the only solution is to update all javascript variables again when the orientation changes. Since I have not yet run huge chunks of updates through javascript, I cannot give much information about the speed and resources of this operation.

+5
source share
4 answers

,

 android:configChanges="keyboardHidden|orientation"

android:configChanges="keyboardHidden|orientation|screenSize"

Android 3.2 " " , , webview . . .

fooobar.com/questions/1106725/...

+4

androidmanifest..... activity

android:name=".YourActivityHere" 
android:configChanges="keyboardHidden|orientation"
0

Try to put it in the manifest

android:configChanges="orientation|keyboardHidden"></activity>

it's in your class

@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
}
0
source

Add the line below to the Android manifest file.

android:configChanges="keyboardHidden|orientation"

0
source

All Articles