Android webview saves form data when orientation changes

How to save form data in web view after orientation change? I used onSaveInstanceState() and I restored the previous state using restoreState(savedInstanceState) . This successfully restores the previous state before changing the orientation, but it does not restore the data in the form text field in the web view.

What needs to be done to save data in the text box of forms in webview after changing orientation?

Note. I would not use android:configChanges="keyboardHidden|orientation" since I need to enter a keyboard for my application after changing the orientation.

Thanks in advance.

+4
source share
1 answer

When the WebView has been destroyed and then recreated, you will need to re-fill the form. You can do this by injecting javascript into the web view

for example, to update text displayed by the status of the identifier of an HTML element

wevView.loadUrl ("javascript: document.querySelector ('# status'). innerHTML = 'some text'");

+1
source

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


All Articles