Proper Rotation with WebView

Make sure your emulator or device has auto-rotate turned on and try rotating your screen. While it does work correctly, you will notice that the WebView has to completely reload the web page. This is because WebView has too much data to save it all inside onSaveInstanceState(…). It has to start from scratch each time it is re-created on rotation.

You may think the easiest way to resolve this problem would be to retain PhotoPageFragment. However, this would not work, because WebView is part of the view hierarchy and is thus still destroyed and re-created on rotation.

For some classes like this (VideoView is another one), the Android documentation recommends that you handle certain configuration changes, ...

Get Android Programming: The Big Nerd Ranch Guide, 4th Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.