title: How to safely turn WebView zooming on and off as needed
body: <p>As mentioned in this unanswered question: <a href="https://stackoverflow.com/questions/4908794/webview-throws-receiver-not-registered-android-widget-zoombuttonscontroller">WebView throws Receiver not registered: android.widget.ZoomButtonsController</a></p>
  
  <p>By turning the WebView zoom controls on and off as needed throws this:</p>
  
  <pre><code>java.lang.IllegalArgumentException: Receiver not registered: android.widget.ZoomButtonsController
  </code></pre>
  
  <p>For some users.  I myself have not seen this crash, but I have seen it in the logs coming from devices in the wild.  It doesn't happen super frequently, but it is a crash regardless.  Any ideas?</p>
  
  <p>Thanks</p>
  
  <p><strong>Update: How to reproduce</strong></p>
  
  <p>I found how to reproduce this crash:  <a href="http://code.google.com/p/android/issues/detail?id=15694" rel="nofollow noreferrer">http://code.google.com/p/android/issues/detail?id=15694</a></p>
  
  <p>I'll report back if I discover a workaround.</p>
  
  <hr>
  
  <p><strong>As requested, the full stack trace:</strong></p>
  
  <pre><code>java.lang.IllegalArgumentException: Receiver not registered: android.widget.ZoomButtonsController$1@487a4290
  at android.app.ActivityThread$PackageInfo.forgetReceiverDispatcher(ActivityThread.java:793)
  at android.app.ContextImpl.unregisterReceiver(ContextImpl.java:913)
  at android.content.ContextWrapper.unregisterReceiver(ContextWrapper.java:331)
  at android.widget.ZoomButtonsController.setVisible(ZoomButtonsController.java:404)
  at android.widget.ZoomButtonsController$2.handleMessage(ZoomButtonsController.java:178)
  at android.os.Handler.dispatchMessage(Handler.java:99)
  at android.os.Looper.loop(Looper.java:123)
  at android.app.ActivityThread.main(ActivityThread.java:4627)
  at java.lang.reflect.Method.invokeNative(Native Method)
  at java.lang.reflect.Method.invoke(Method.java:521)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
  at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p>and another similar one:</p>
  
  <pre><code>java.lang.IllegalArgumentException: View not attached to window manager
  at android.view.WindowManagerImpl.findViewLocked(WindowManagerImpl.java:391)
  at android.view.WindowManagerImpl.removeView(WindowManagerImpl.java:236)
  at android.view.Window$LocalWindowManager.removeView(Window.java:432)
  at android.widget.ZoomButtonsController.setVisible(ZoomButtonsController.java:406)
  at android.widget.ZoomButtonsController$2.handleMessage(ZoomButtonsController.java:178)
  at android.os.Handler.dispatchMessage(Handler.java:99)
  at android.os.Looper.loop(Looper.java:143)
  at android.app.ActivityThread.main(ActivityThread.java:5068)
  at java.lang.reflect.Method.invokeNative(Native Method)
  at java.lang.reflect.Method.invoke(Method.java:521)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
  at dalvik.system.NativeStart.main(Native Method)
  </code></pre>