PZolee posted on this subject and a proposed solution in his blog: https://pzoleeblogen.wordpress.com/2014/07/08/android-how-to-solve-adview-cpu-consuming/
I investigated this further (in the comments to the blog post are documented my struggles) and came to the following conclusion:
- Indeed, calling just adView.pause(); does not stop Google Ads component from consuming CPU even if the app is in background and ads are not visible.
- Finding all the WebViews inside a our adView and calling onPause() and onResume() WevView methods on them does not solve the problem of the unnecessary CPU consumption.
- Only the call to WebView pauseTimers() and resumeTimers() methods as the author of the above post proposes does stop the unnecessary CPU consumption.
- Finding recursively all the WebViews and calling pauseTimers() and resumeTimers() on all of them is unnecessary, since one such call “Pauses (or resumes – g.) all layout, parsing, and JavaScript timers for all WebViews. (within a process – g.)” – see WebView component docs.
- If you use a WebView anywhere else in your app – maybe in other activities, you must resumeTimers() for it, or it won’t work right. Also, be aware that a WevView may be constructed temporarily and used by some library functions you use in your project, without you explicitly knowing about it. It could be e.g. a prompt to login to some web site, social network etc. Such WebView may again not work right, if pauseTimers() was called in your process somewhere and you did not resume them. USE CAUTION AND TEST all you can.
It’s really a shame, that Google and AdMob handled us such a nasty surprise with their ad component (constant CPU consumption even if you background the app, hide their component, even pause() it with their own API call…