1

I needed to pass a WebView to another Activity, and I couldn't create a new WebView in the new Activity because the html content can not be loaded twice. So I managed to solve the problem using a static blackboard and the MutableContextWrapper.

The approach was: (i) The original Activity instantiates the WebView with a MutableContextWrapper, and before to start the second Activity, (ii) I detach the WebView from the original Activity, (iii) store it in a static blackboard, and when the second Activity is started, (iv) it gets the instance of WebView on the blackboard, (v) updates its Context using the MutableContextWrapper, (vi) and attach it to the new Activity. When the second Activity is closed, the reverse way is followed to put back the WebView in the original Activity.

This approach works very well in the most Android versions, but since the Lollipop version, the WebView does not refresh its content while it is attached to the second Activity. However when the second Activity is closed and the WebView goes back to the original Activity, it works fine.

In my researches, I discovered about the new behavior of the WebViews from the Android L that reduces memory footprint and increases performance by intelligently choosing the portion of the HTML document that needs to be drawn.

So I suspected that this feature could interfere in the WebView's refreshing, but even calling the enableSlowWholeDocumentDraw() method, the WebView continues not working properly.

Someone would know explain the cause for this behavior?

Doron Yakovlev Golani
  • 5,188
  • 9
  • 36
  • 60
lpmfilho
  • 178
  • 6

0 Answers0