Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. COYour first "easiest" way to do this is the only way. The "more modern approach" won't work in this case (well, it'll work, but it'll leak memory) because a WebView is tied to an Activity's Context upon instantiation. Check out [Dianne Hackborn's comments on that](https://groups.google.com/forum/#!msg/android-developers/cWnxkQ8RLeY/RA1n77EDeR8J).
      singulars
    2. CO@mkuech: The latter is the case for any view, not just `WebView`s - that's why you'll always find yourself re-inflating views on a fragment level in `onCreateView()` or `onActivityCreated()`. I didn't go into specifics in my answer above, but with `setRetainInstance(true)` you could make the 'old' `WebView` save its state to a bundle and restore it afterwards. It does mean the `WebView` will have to rebuild its content (read: reload the url), so it's visually not as fast/smooth as handling the `Activity`'s configuration changes manually.
      singulars
    3. COBut you don't need to use a `Fragment` to save a `WebView`'s state. You can just use the standard state management methods from the `Activity` or `Fragment` if that's all you need. `setRetainInstance(true)` isn't _normally_ needed for this simple use case. It more just replaces `onRetainNonConfigurationInstance`, and is useful for things like keeping a `Thread` active across configuration changes. I'd avoid complicating things. Besides, since merely saving a `WebView`'s state won't keep it from redrawing/reloading, the first solution is the only real way to keep it seamless when rotating.
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload