Home » Android » WebView throws Receiver not registered: android.widget.ZoomButtonsController

WebView throws Receiver not registered: android.widget.ZoomButtonsController

Posted by: admin May 14, 2020 Leave a comment

Questions:

I see this exception sporadically raising up in my application (in the wild).
The WebView is used to display a jpg (using the zoom/scroll-capabilities of the Android version/the device instead reinventing the wheel and do all the reflection stuff).

I have no idea why this exception eventually could come up. Basically I can only think of an Android bug.

What I do (everything in GUI thread):

  • display a thumbnail as preview first
  • set getSettings().setBuiltInZoomControls(false)
  • when the regular picture is loaded, display that one instead
  • set getSettings().setBuiltInZoomControls(true)

Why setting ZoomControls on/off: The thumb should not be zoomable, as the WebView resets this on loadData as soon as the regular picture is available and displayed. Would be some bad user experience.

Example device this is happening:
HTC [email protected]_wwe/htc_bravo/bravo/bravo:2.2/FRF91/226611:user/release-keys

I have exactly the same device/software and it never happend to me…

Any ideas?

Regards,
Oliver

How to&Answers:

I don’t like to answer myself, but littleFluffyKitty did not (only in comment).

Solution is in How to safely turn WebView zooming on and off as needed

a) create your own WebView class

public class MyWebView extends WebView {

b) add in it’s onDestroy() method:

getSettings().setBuiltInZoomControls(true);

That’s it. Thanks to that, no more of those Exceptions show up.