7

I'm currently somewhat confused as to how (or if?) I'm supposed to manage the lifecycle of the WebViews in my Android application. The app seems to have a much bigger impact on the devices battery than I think it should have and I suspect the cause might be mismanagement of the WebViews on my part. The answers I found only ever seem to raise part of the problem and I couldn't find some kind of tutorial or more general answer on this so far.

When I started developing my application, I thought that WebViews were supposed to follow the lifecycle of their respective Activity, then I stumbled across the methods onPause, onResume, pauseTimers, resumeTimers, saveState and restoreState.

But I don't really unterstand what implications each one of these have for the lifecycle of their WebView and what it means for battery/memory/CPU management to use or not use any of these. This answer mentioned it'd be "cheaper to destroy the webviews and recreate them again", but didn't go into further detail and the posted link is dead.

Could anyone please give a brief explanation and introduction on what is best practice for managing a WebViews lifecycle?

Patneu
  • 1,021
  • 1
  • 9
  • 10

0 Answers0