1

I’m happy to learn that the navigation library finally saves and restores Fragment state since version 2.4 (release notes ), which is useful in a Bottom Navigation scenario to not completely rebuild screens when switching tabs.

Before, I would resort to a not-so-great subclass of FragmentNavigator that would detach / re-attach the Fragments, to retain it completely, including scroll-position etc. I would be super happy to get rid of this custom subclass, but I ran into this problem:

Now, When switching to a Fragment that contains a WebView (I know, :disappointed: ), the webview will reload when I select the tab that contains it, even when using webView.restoreState() (this will only restore what url was loaded last along with the navigation history, I believe)

Has anyone figured out how to completely retain a WebView ’s state when switching tabs? That is, without any reloading going on?

Nino van Hooff
  • 3,677
  • 1
  • 36
  • 52
  • Probably not what you want to hear, but I don't believe this is possible anymore. From the API documentation for `WebView.restoreState()`: `Please note that this method no longer restores the display data for this WebView.` Hopefully I'm wrong, because I would also prefer to not reload the content when restoring state. – var47 Dec 01 '22 at 23:56

0 Answers0