0

In my tiny application, I get what I need from a web page after the first onNewPicture().

But WebView's PictureListener keeps bombarding my application with onNewPicture() callbacks... This is despite WebSettings.setBlockNetworkImage() set to true.

Is there a way to tell WebView to stop listening/sending/processing onNewPicture()s?

uTubeFan
  • 6,664
  • 12
  • 41
  • 65

1 Answers1

1

Is there a way to tell WebView to stop listening/sending/processing onNewPicture()s?

Off the cuff, I would call setPictureListener(null) on the WebView, once you no longer need to be notified.

Note that PictureListener is marked as deprecated, though off the top of my head I have no idea what is replacing it.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Thanks! "deprecated" means it's still available (for backward compatibility), but not recommended for use, right? – uTubeFan Oct 17 '11 at 18:46
  • @uTubeFan: Right. However, I'd be a tad more nervous about this one, simply because it is tied into WebKit. It is conceivable that upstream changes in WebKit are driving the deprecation and that support for `PictureListener` might be totally lost in some future release. I feel more comfortable about Google maintaining backwards compatibility when they have more control over matters. I'd just keep a close eye on any new Android OS releases and confirm that `PictureListener` still works, plus see if there is a better-supported alternative going forward. – CommonsWare Oct 17 '11 at 18:57
  • I just tested an implementation of your proposed `setPictureListener(null)` and it works! I wonder now whether `WebSettings.setBlockNetworkLoads(false)` would achieve the same effect (with the added benefit of reducing "bandwidth consumption"). – uTubeFan Oct 17 '11 at 20:15